Nis*_*nce 8 html javascript iframe jquery
我的概念是从iframe更新主页面中文本框的值.此代码工作中firefox,但没有工作Internet Explorer和Chrome.双方main.html并frame.html都在同一个位置.我需要建议让它在所有浏览器中运行.
main.html中
<!DOCTYPE html>
<html>
<head>
<title> main window </title>
</head>
<body>
Parent textbox :<input type="text" id="parentbox"></br></br></br>
<iframe src="frame.html" ></iframe>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
frame.html
<!DOCTYPE html>
<html>
<head>
<title> frame window </title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
function PushValues()
{
var frame_value = document.getElementById("framebox").value;
window.parent.document.getElementById("parentbox").value =frame_value;
}
</script>
</head>
<body>
<input type="text" id="framebox" >
<input type="button" value ="fill" onclick="PushValues()">
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
既然你正在使用 jQuery 试试这个
var frame_value = $('#framebox').val();
$('#parentbox', window.parent.document).val(frame_value);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13434 次 |
| 最近记录: |