setTimeOut 时间放长点, 可能控件加载的速度问题
解决方案 »
- my eclipse那个版本比较好
- 想要一个邮箱验证的 正则表达式 可以验证 [email protected]这种的....
- 火狐下的拖动问题
- (在线等)javascript根据URL判断是否刷新问题!!
- JS下打开本地文件的问题
- Javascript 操作文本文件
- 以下是我在网上找到的一个关于读取Cookie的js代码,是用正则写的,求助
- IE弹出如下内容怎么好解决
- 一个js与jsp使用变量的问题,大家看看,谢谢
- 请教js正则高手
- fckeditor 编辑器在.net创建的网站的页面上浏览时总是说不到页面,但同样的代码在web应用程序的网站上就可以??
- iframe嵌入第三方网页,如何限制第三方页面替换parent页面
最奇怪的是别人的页面没这问题我的出现这样的问题了!
如果不设setTimeOut的话,重新打开必定会出现js错误。
后来在使用了alert("0")后就不会出现了!这是在<body>Onload里执行的!
setTimeout("InitData()", 300);
function InitData()
{
// var now = new Date();
// var time=now.getYear()+"/"+(now.getMonth()+1)+"/"+now.getDate();
// document.getElementById("labMDate").innerHTML=time.substring(2,time.length);
document.getElementById("lblConfirmTime").innerHTML = window.opener.document.getElementById("txtSDate").value.replace("/","").replace("/","")+" 至 "+ window.opener.document.getElementById("txtSDate").value.replace("/","").replace("/","");
……
</script>
</head>
<body>
<form id="form1" runat="server">
这是子页面的部分代码,就是InitData的第一句在重新打开时会报错。如果隔段时间再打开就不会报错(父页面不关闭)!
{
// var now = new Date();
// var time=now.getYear()+"/"+(now.getMonth()+1)+"/"+now.getDate();
// document.getElementById("labMDate").innerHTML=time.substring(2,time.length);
document.getElementById("lblConfirmTime").innerHTML = window.opener.document.getElementById("txtSDate").value.replace("/","").replace("/","")+" 至 "+ window.opener.document.getElementById("txtSDate").value.replace("/","").replace("/","");
document.getElementById("labHouseNo").innerHTML=window.opener.document.getElementById("txtHouseNo").value; var SourceID = window.opener.document.getElementById("txtRelatedNo").value;
var OHomeNo = window.opener.document.getElementById("txtHouseNo").value;
var ProNo = window.opener.document.getElementById("txtProNo").value;
var ProName = window.opener.document.getElementById("txtProName").value;
var ProVision = window.opener.document.getElementById("txtProVision").value;
var ComNo = window.opener.document.getElementById("txtComNo").value;
var ComName = window.opener.document.getElementById("txtComName").value;
var ConfirmTimeS = window.opener.document.getElementById("txtSDate").value;
var ConfirmTimeE = window.opener.document.getElementById("txtEDate").value;
var xml = WebForm1.GetDataSource(SourceID,OHomeNo,ProNo,ProName,ProVision,ComNo,ComName,ConfirmTimeS, '').value; //获取值
if(xml=="")
{
// document.getElementById("labEmpDateInfo").style.display="";
alert( '查無數據!' );
window.close();
}
else
{
BindXMLTable( "divTab", xml); //梆定Table
}
}
当没有数据后,再打开会报错!
换成document.body.onload = InitData;看看
<body onload="InitData()">么?
最开始是这样写的,会报找不到父页面错误的。
原因是:当点击打开子窗体的回发瞬间(我用的是asp.net的服务器控件),子窗体onload时正好在父窗体点击按钮与回发完成前,是找不着父页面的控件的,这时候父页面控件还未生成!
改为input标签,然后把代码改成js的就行了。