2016-09-15 60 views
-1

如何在Chrome瀏覽器中使用JavaScript加載遊戲?Iframe src改變Javascript未加載Chrome瀏覽器

的Javascript:

document.getElementById('game').src = "www.example.com"; 

使用IFRAME:

<iframe src="/games/game.html" id="game" 
style="display:block;margin:0 auto;" width="100%" height="100%" 
frameborder="0" allowfullscreen="true" webkitallowfullscreen="true" 
mozallowfullscreen="true" ></iframe> 

或Flash:

<embed src="/games/game.swf" id="game" quality="high" 
pluginspage="http://www.macromedia.com/shockwave/download/index.cgi? 
P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" 
width="100%" height="100%"> 
+0

您是否嘗試將相對路徑更改爲「./games/game.html」? – mrapsogos

回答

1

入住這jsfiddle

它的伎倆使用jQuery。

$("#click").click(function(){ 
$("#game").attr("src","https://jsfiddle.net/user"); 
}); 

HTML

<span id="click">X</span> 
<iframe src="https://jsfiddle.net/user/login/" id="game" 
style="display:block;margin:0 auto;" width="100%" height="100%" 
frameborder="0" allowfullscreen="true" webkitallowfullscreen="true" 
mozallowfullscreen="true" ></iframe> 

你可能有一些問題,你的路徑,所以你可能還需要檢查控制檯錯誤。

相關問題