简体   繁体   English

如何在iframe中动态加载页面

[英]How to load page dynamically in iframe

I just want to load an html page in iframe on clicking a link or button in the same page. 我只想在点击同一页面中的链接或按钮时在iframe中加载html页面。 I used javascript to load the page dynamically. 我使用javascript动态加载页面。 But, I couldn't do that. 但是,我做不到。 Please anyone guide me to do that. 请有人指导我这样做。 My code is as follows: 我的代码如下:

document.getElementById("iframeelem").src="newhtml.jsp";

Put this on the embedded page 把它放在嵌入页面上

<p>
<input type='button' name='Next' value='Next Page'
onclick='window.location.replace("http://timecrystal.co.uk/");' />
</p>

Your code is correct. 你的代码是正确的。 Here is a tutorial, just in case: http://www.dyn-web.com/tutorials/iframes/ 这是一个教程,以防万一: http//www.dyn-web.com/tutorials/iframes/

What is the error? 错误是什么?

Verify the id of your frame and url are correct (type in the url in a browser window and make sure you get your page). 验证您的框架和网址的ID是否正确(在浏览器窗口中输入网址并确保获取您的网页)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM