我試圖基本上從一個單獨的網站使用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>
我猜這不是由於跨域工作。那裏有什麼解決辦法?
這是在IE嗎? ..似乎在Chrome/Safari中工作 – user1428716 2013-03-02 22:17:01
似乎在Opera/Chrome/IE7中爲我工作。 – hjpotter92 2013-03-02 22:18:09
雖然正在使用Chrome/Safari - 您將在控制檯中得到一個JS錯誤 – user1428716 2013-03-02 22:22:40