Javascript onblur影响从文本框输入到iframe
Javascript onblur affect from text box input to iframe?
我正试图在表单文本输入中键入一个url,在Blur上,用url中指定的网页更新包含的iframe的内容。我似乎无法让它发挥作用,我也不明白为什么…:)
有人能帮我吗?
这是代码。。。
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<script language="javascript" type="text/javascript" >
<!-- hide
function setIframeSource() {
var theSelect = document.getElementById('location');
var theIframe = document.getElementById('myIframe');
var theUrl;
theUrl = document.getElementById("location");
theIframe.src = theUrl;
}
// end hide -->
</script>
</head>
<body><center>
<form id="form1" method="post">
<input type="text" style="width:150px;" name="location2" id="location" onBlur="setIframeSource();">
</form>
<table width="100%" height="100%" border="1">
<tr>
<td width="300"><iframe src="http://www.ibm.com" id="myIframe" width="280" height="300" name="frame1"></iframe></td>
</tr>
</table>
</center>
</body>
</html>
function setIframeSource() {
var theSelect = document.getElementById('location');
var theIframe = document.getElementById('myIframe');
var theUrl;
theUrl = document.getElementById("location");
theIframe.src = theUrl;
}
也许问题出在上面的第5行——应该是:
theUrl = document.getElementById("location").value;
目前,您正在将输入元素本身分配给theUrl
,这不是theIframe.src
的有效值!
在设置iframe
的src
:后尝试添加此项
theIframe.contentDocument.location.reload(true);
并且,从输入中获取值:
document.getElementById('location').value;
相关文章:
- 通过提示中的循环触发iFrame中的输入按钮(JavaScript)
- 使用输入类型text更改iframe-src
- ckEditor插件iframe对话框设置html输入
- iframe 中输入上的模糊/焦点事件(委派)
- mouse在 iframe 的内容中输入鼠标离开
- Firefox Mobile 阻止在 iframe 中输入
- 使用 Jquery 将输入数据发送到 iframe 之外
- 设置外部 iframe 内输入字段的值
- 如何使用 iframe 作为 YT 的输入.选手
- 在另一个页面上使用输入框更改 iframe 的 src
- 条纹 - 更改 iframe 输入的固定器
- 如何使用 Javascript 动态加载 iFrame 源代码和自动填充输入表单
- 将文本从 IFRAME 复制到父页面上的输入字段中
- Iframe 发布表单 - 在更改输入字段时提交 html 表单
- 获取 IFrame 源,然后更新输入文本框
- 将文件从输入传输到 iframe JavaScript
- 如何检查鼠标是否以纯javascript输入iframe
- 没有将JavaScript输入iframe
- 使用提前输入iFrame
- 如何为YouTube视频手动输入iframe捕获OnStateChange事件