【发布时间】:2020-05-05 10:07:54
【问题描述】:
我想使用 URL 更改 iframe src URL。例如,如果我将这个 URL http://simplesite.com/videoiframe.html?txtUrl=https://www.simplesite.com&press=Go 输入到浏览器并提交,它应该将 iframe 的 src 部分更改为 https://www.simplesite.com 并按下按钮“Go”。
这是我的代码:
<!DOCTYPE html>
<html>
<script type="text/javascript">
function setBrowserFrameSource(){
var browserFrame = document.getElementById("browser");
browserFrame.src= document.getElementById("txtUrl").value;
}
</script>
</head>
<div visibility="hidden">
<form method="post" target="browser">
<input id="txtUrl" style="width:82%;" placeholder="Put the website here" name="url" type="text" />
<input style="width:8%;" type="button" value="Go" onclick="setBrowserFrameSource(); return false;"/>
</form>
</div>
<iframe id="browser" name="browser" src="http://google.com" style="height:100%; width:100%"></iframe>
</html>
【问题讨论】:
-
注意:
<input>标签不使用也不需要结束斜线,并且在 HTML 中从来没有。
标签: javascript html url curl get