Iframe src 更改为 Javascript 未加载 Chrome
Iframe src changed with Javascript not loading with Chrome
如何在 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>
或闪存:
<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%">
勾选这个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>
您的路径可能有一些问题,因此您可能还需要检查控制台是否有错误。
如何在 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>
或闪存:
<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%">
勾选这个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>
您的路径可能有一些问题,因此您可能还需要检查控制台是否有错误。