我试图从其他域重新加载父页面。关闭子项时,我在父页面上实现了重新加载,但是一旦我重新加载,onclick
事件上的操作再次触发。我的问题是,一旦重新加载,我该如何阻止window.open
?
这是代码:
// here I've added `return false` but it fails to prevent the popup
<asp:HyperLink ID="HyperLink1" runat="server" onclick="return myopen('https://www.example.org/applicant/getdrivers?ApplicantId=15647&type=0', 'VieworUploadDocs','toolbar=no,location=no,directories=no,status=no,menubar=no,position=center,width=700px,height=850px');return false;" Text="Click Here" />
剧本:
<script type="text/javascript">
//open window
var myWindow = null;
var myTimer = null;
myopen = function (url) {
myWindow = open(url, 'VieworUploadDocs', 'toolbar=no,location=no,directories=no,status=no,menubar=no,position=center,width=700px,height=850px');
myTimer = setInterval(function (e) {
if (myWindow == null || myWindow.closed) {
alert('Please wait while page loads.');
location.reload();
clearInterval(myTimer);
e.stopPropagation();
}
}, 5000);
}
</script>
我也试过把它放在我的代码中:
return false;
e.preventDefault();
e.stopPropagation();