2015-11-02 39 views
0

我使用iframe將lumextech.com作爲默認src加載到框架中,當我使用lumextech.com搜索並移動到其他網頁時但仍然在iframesrc其顯示lumextech.com只有我想要捕捉網頁的網址,在iframe加載...注:我沒有控制上lumextech.com ....javascript jquery,web development

我的代碼:

<! DOCTYPE html> 

<html> 
    <head> 
    <script type="text/javascript" src="jquery.min.js"></script> 
    </head> 

    <body> 
       <section> 
        <h3> welcome to Iframe</h3>      

        <script type="text/javascript"> 


         $(function(){ 
          $('#submit').click(function(){ 
           $url = $('#iframeContent').attr('src'); 
           $('#demo').html($url);        
          }); 
         }); 


        </script> 

        <input type="submit" id="submit" value="showUrl"/> 
        <div id="demo"></div> 

        <iframe id="iframeContent" src="http://lumextech.com" style="min-height: 500px; min-width: 500px;"></iframe>    


       </section> 
    </body> 

</html> 
+0

同源策略限制工作的良好防止一個IFRAME –

+0

這樣的訪問應該有辦法........ !!!!!!!! –

回答

1

你在你的src有一個錯字插入功能。字符串中的額外空白區域。在這個Codepen

$('#frameid').attr('src', 'http://lumextech.com/'); 
+0

好吧,我刪除了空間,但主要問題呢......我怎麼能得到當前的網址........ –

+0

應該有一種方式.......... ????? –

+0

There should ... gimme sec – ALFmachine