使用javascript函数在iFrame中加载页面 [英] Using a javascript function to load a page in an iFrame
本文介绍了使用javascript函数在iFrame中加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Javascript函数在名为cake的iframe中加载网页。我怎样才能做到这一点?
I'm trying to use a Javascript function to load a web page in an iframe named "cake". How can I do that?
<html>
<head>
</head>
<body>
<button onclick=[function]>Load page in iframe</a>
</body>
</html>
推荐答案
function changeUrl() {
var site = "http://www.w3schools.com";
document.getElementsByName('iFrameName')[0].src = site;
}
<html>
<head>
</head>
<body>
<button onclick="changeUrl()">Load page in iframe</button>
<iframe name="iFrameName"></iframe>
</body>
</html>
这篇关于使用javascript函数在iFrame中加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文