Iframe src改变与Javascript不加载Chrome

Iframe src changed with Javascript not loading with Chrome

本文关键字:加载 Chrome Javascript src 改变 Iframe      更新时间:2023-09-26

如何在chrome上加载javascript游戏?

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%">

Check This jsfield

它用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>

您的路径可能有一些问题,因此您可能还需要检查控制台是否有错误。