子窗口onload事件写到父窗口怎样写? win = window.open('a.htm','','');win.onload = function(){} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 win = window.open('a.htm','','');win.document.body.onload = function(){} win = window.open("",""); win.onload=function(){alert()}我之前就这样写过,但不好用 <SCRIPT>onload=function(){ for(var i=0;i<myTab.rows.length;i++) { for(var j=0;j<myTab.rows[i].cells.length;j++) { if(i!=0) { eval("myTab.rows["+i+"].cells["+j+"].onclick=function(){window.opener.form1.project.value = myTab.rows["+i+"].cells[1].innerText}"); eval("myTab.rows["+i+"].cells["+j+"].onmouseup=function(){opener.focus()}"); eval("myTab.rows["+i+"].cells["+j+"].onmouseup=function(){self.close()}"); } } }}</SCRIPT>这是我一个程序里的代码,是单击选种表格中一行返回第2格内容并关闭自己,你看看有没有用 <html><head><title>ParentWin</title><script language=javascript><!--function doSubWinLoad(subWin){ window.alert("这是父窗口的对话框"); subWin.alert("这是子窗口的对话框");}function openSubWin(){ open('subWin.htm','sub');}</script></head><body> <a href="javascript:openSubWin();">打开</a></body></html>---------------------------------------subWin.htm:<html> <head><title>subWin</title></head> <body onload="window.opener.doSubWinLoad(window);"> 这是子窗口 </body></html> 就是子窗口不写代码,让父窗口判断子窗口的onload 这样应该是不行的,因为子窗口里的代码全部是写进去的,所以第一次载入是没有事件发生的,你可以看看:当打开子窗口后,没有alert,但刷新之后会有<script language="javascript"><!--var w=window.open("","","")w.document.write("<script>onload=function(){alert('blueDestiny')}</scr"+"ipt>");//--></script> 当然有变通的办法。在子窗口内加入hidden,初始为0,当为0时,hidden为1,刷新页面。也可以出现alert但更好的办法,我觉得还不如直接把事件加入body末端,这样把一个true值告诉给opener,也可以达到你的目的。 <script language=javascript>function outPut(){var text = "admin";var win = window.open("Untitled2.html","mywin", "menubar=yes,width=400,height=100,resizeable=yes");win.document.onreadystatechange=function(){ if(document.readyState=="complete"){ win.document.form1.username.value=text; } } }</script><!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=gb2312" /><title>无标题文档</title></head><body><a href="#" onClick="outPut()">ssss</a><form id="form1" name="form1" method="post" action=""> <label> <input name="username" type="text" id="username" /> </label></form></body></html> 发送表单后,如何使接收内容是一个表格 js怎么设置ie6的top和bottom属性 String.prototype问题 浮动菜单点击调用flash动画的问题? 手机浏览页面 js弹不出时间控件 ext talbe布局 中item 项如何将单元格内的文字居中啊? 求教一个现象!! hi ,做了一个漂亮的窗口操作类,给大家分享下 求一简单正则表达式 请问如何用javascript实现汉字转换拼音 如何用javascript生成指定长度字符串 遇到一个奇怪问题,关于HighCharts的全局变量的。
win.document.body.onload = function(){
}
win.onload=function(){alert()}
我之前就这样写过,但不好用
onload=function()
{
for(var i=0;i<myTab.rows.length;i++)
{
for(var j=0;j<myTab.rows[i].cells.length;j++)
{
if(i!=0)
{
eval("myTab.rows["+i+"].cells["+j+"].onclick=function(){window.opener.form1.project.value = myTab.rows["+i+"].cells[1].innerText}");
eval("myTab.rows["+i+"].cells["+j+"].onmouseup=function(){opener.focus()}");
eval("myTab.rows["+i+"].cells["+j+"].onmouseup=function(){self.close()}");
}
}
}
}
</SCRIPT>
这是我一个程序里的代码,是单击选种表格中一行返回第2格内容并关闭自己,你看看有没有用
<head>
<title>ParentWin</title>
<script language=javascript>
<!--function doSubWinLoad(subWin){
window.alert("这是父窗口的对话框");
subWin.alert("这是子窗口的对话框");
}
function openSubWin(){
open('subWin.htm','sub');
}
</script></head>
<body>
<a href="javascript:openSubWin();">打开</a>
</body>
</html>---------------------------------------
subWin.htm:
<html>
<head><title>subWin</title></head>
<body onload="window.opener.doSubWinLoad(window);">
这是子窗口
</body>
</html>
当打开子窗口后,没有alert,但刷新之后会有
<script language="javascript">
<!--
var w=window.open("","","")
w.document.write("<script>onload=function(){alert('blueDestiny')}</scr"+"ipt>");
//-->
</script>
function outPut()
{
var text = "admin";
var win = window.open("Untitled2.html","mywin", "menubar=yes,width=400,height=100,resizeable=yes");win.document.onreadystatechange=function(){
if(document.readyState=="complete"){
win.document.form1.username.value=text;
}
} }</script><!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=gb2312" />
<title>无标题文档</title>
</head><body>
<a href="#" onClick="outPut()">ssss</a>
<form id="form1" name="form1" method="post" action="">
<label>
<input name="username" type="text" id="username" />
</label>
</form>
</body>
</html>