2011-01-24 31 views
0

我已經在HTML中定義了一個IFrame。 從JavaScript我試圖改變IFrame的URL(src屬性)。它在大多數網址上都可以正常工作。但是,當我嘗試設置不止一次的eBay項目URL時,它將在整個窗口中打開。Iframe javascript src設置在整個窗口中打開

這裏是我的代碼:

<html> 
    <head> 
     <script type="text/javascript"> 
      function seturl(){ 
       var txt=document.getElementsByName("txt"); 
       document.getElementById('testframe').src = txt[0].value;  

      } 
     </script> 
    </head> 
    <body> 
     <iframe id="testframe" width= "700" height="500" > 
     </iframe> 
     <input type="text" name="txt" width="700"/> 
     <input type="button" value="Click me!" onclick="seturl()" /> 
    </body> 

    </html> 

是否有任何解決方案,以避免整個頁面此易趣物品URL打開?

http://cgi.ebay.com/Apple-iPad-Wi-Fi-32GB-BRAND-NEW-NO-RESERVE_W0QQitemZ220725228457QQcategoryZ171485QQcmdZViewItem

回答