使用 javascript 将页面加载到 Iframe

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18714366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 12:57:51  来源:igfitidea点击:

Load Page to Iframe with using javascript

javascripthtmliframe

提问by user2622044

I got Page work with parameter and ? want to show it in iframe. however when ? set to iframe location my iframe not load all javascript. Normally Page works. My ?frame was working too. but now it is not working. why?

我让 Page 使用参数和 ? 想在 iframe 中显示它。然而什么时候?设置为 iframe 位置我的 iframe 不加载所有 javascript。通常页面工作。我的 ?frame 也在工作。但现在它不工作了。为什么?

 window.frames["MyFrame"].location = "Component/Component.php?pagename="+$(Element).attr("page-name");

it is my javascript code for set iframe location.

这是我用于设置 iframe 位置的 javascript 代码。

回答by Cherniv

Try srcattribute:

尝试src属性

window.frames["MyFrame"].src = //...

回答by SarathSprakash

Try this

试试这个

document.getElementById('MyFrame').src="Component/Component.php?pagename="+$(Element).attr("page-name");