2012-07-26 57 views
0

的iFrame在jQuery Mobile的應用程序導致錯誤:Unsafe JavaScript attempt to access frame with URL file:///D:/xx/webpage.html from frame with URL http://www.asp.net/. Domains, protocols and ports must match.的iFrame在jQuery Mobile的應用程序導致錯誤

我正在開發使用iframe來加載外部網站jQuery的移動應用程序。
我的腳本代碼是:

$(document).ready(function() { 

$('#divID').prepend('<img src="http://xxx/images/ICPosternew1002.png" usemap="#map" id="image" style="margin-top:43px;"/>') 
    $('#map').append('<area coords="30,0,60,30" id="1" alt="Blah" title="asp" />') 
    $("#1").bind("click", function (e) {     
    e.preventDefault();   
      $('#Web1').append('<form id="form1" runat="server" rel="external"></form>')    
     $('#form1').append('<iframe id="iframe1" src="http://asp.net" frameborder="0" rel="external"></iframe>') 
     }); 
    }); 

我在我的應用程序的兩個虛擬頁。點擊主頁上的圖像地圖後,加載第二頁與iFrame和相應的網站。

  <div data-role="page" id="Web" class="pagebody"> 
    <div data-role="header" data-position="inline" data-theme="a"> 
      <!--header--> 
     </div> 
     <div data-role="content" id="Web1"> 
    <form id="form1" runat="server"> 
      <iframe id="iframe1" > 
      </iframe> 
      </form> 
     </div> 
     <div data-role="footer" class="footer"> 
      <!--footer--> 
     </div> 
    </div> 

這是我的代碼問題嗎?

回答

0

我想你可以解決這樣說:

     $(document).ready(function() { 

        var html = ""; 
        html += "<div data-role=page id=win2 class=pagebody>"; 
        html += "<div data-role='header'>"; 
        html += "</div>"; 
        html += "<div data-role=content>"; 
        html += "</div>"; 
        html += "<div class=push>"; 
        html += "</div>"; 
        html += "<div data-role=footer class=footer>"; 
        html += "</div>" 
        html += "</div>"; 
        $(html).insertAfter ("#index"); 
        for(var i=0;i<data.length;i++) 
        { 
         $("#area"+data[i].NodeID+"").bind ("click", function (event) 
         { 
          var title = $(this).attr("src"); 
          alert(title); 
          $.mobile.changePage ($("#win2")); 
          $("#win2 div:jqmData(role=content)").empty().append ('<form id="form1" runat="server" rel="external"></form>') 
          $('#form1').empty().append('<iframe id="iframe1" src="'+title+'" frameborder="0" rel="external"></iframe>') 
         }); 
        }  
     }); 
相關問題