【问题标题】:Iframe src changed with Javascript not loading with Chromeiframe src 更改为 Javascript 未使用 Chrome 加载
【发布时间】:2017-01-23 15:34:56
【问题描述】:

如何在 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%">

【问题讨论】:

  • 您是否尝试过将相对路径更改为“./games/game.html”?

标签: javascript jquery google-chrome iframe embed


【解决方案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>

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

【讨论】:

    猜你喜欢
    • 2011-04-13
    • 1970-01-01
    • 2015-02-01
    • 2018-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-26
    • 2023-03-28
    相关资源
    最近更新 更多