2013-03-02 55 views
0

我試圖基本上從一個單獨的網站使用jQuery啓動遊戲。使用觸發器('點擊')與jQuery跨域

http://webstudios.webs.com/rbxlaunch.htm

我的來源是

<html> 
    <head> 
     <title>ROBLOX Games!</title> 
     <iframe width="100%" height="100%" id="Frame" seamless src="" scrolling=no style="position: absolute; top: 200px; left: 0px;"></iframe> 
     <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
     <script> 
      function VisitPlace(ID) { 
       alert("Clicked."); 
       $('#test').trigger('click'); 
       document.getElementById("Frame").src = "http://www.roblox.com/--place?id=" + ID; 
       $("#Frame").load(function(){ 
        alert("Done loading."); 
        $('#Frame').contents().find("#ctl00_cphRoblox_VisitButtons_MultiplayerVisitButton").trigger('click') 
             alert("Enjoy the game"); 
       }); 
      } 
     </script> 
    </head> 
    <body> 
     <center> 
      <button onclick="javascript:VisitPlace(487316);">ROBLOX remote visit test.</button> 
      <button id="test" onclick="javascript:alert('Hello');">Ignore me.</button> 
     </center> 
</body> 
</html> 

我猜這不是由於跨域工作。那裏有什麼解決辦法?

+0

這是在IE嗎? ..似乎在Chrome/Safari中工作 – user1428716 2013-03-02 22:17:01

+0

似乎在Opera/Chrome/IE7中爲我工作。 – hjpotter92 2013-03-02 22:18:09

+0

雖然正在使用Chrome/Safari - 您將在控制檯中得到一個JS錯誤 – user1428716 2013-03-02 22:22:40

回答

0

沒有人爲干預,服務器端行動或來自目標站點的合作,據我所知沒有什麼可以做的。

+0

我正在評估在我的控制下,兩個域名都有類似的地方那麼,如果我們確實能夠控制目標網站呢? – skaneria 2013-04-12 19:36:02

+0

@skaneria然後問題中的代碼示例應該爲你工作:$('#Frame')。contents()... – Christophe 2013-04-12 22:05:39