[英]Why page gets blank with “[Object]” after javascript:window.open?
I've put a link on one page that opens a new window. 我在一个页面上放了一个链接,打开一个新窗口。 the markup it's:
标记是:
Click <a href="javascript:window.open('../SomePage.aspx', 'mynewwin', 'width=880,height=600,toolbar=0,scrollbars=1,resizable=1');" >HERE</a>.
It happens that when I click the link, the new page shows perfect, but the old one gets blank and only "[Object]" it's writen on it. 碰巧当我点击链接时,新页面显示完美,但旧页面变为空白,只有“[对象]”才会在其上写入。 It should stay as it was.
它应该保持原样。
It's weird! 有点奇怪!
Because you are not cancelling the click action. 因为您没有取消点击操作。
Click <a href="javascript:window.open('../SomePage.aspx', 'mynewwin', 'width=880,height=600,toolbar=0,scrollbars=1,resizable=1');return false;" >HERE</a>
ideally you would not use the href to open the window. 理想情况下,您不会使用href打开窗口。
<a target="_blank" href="../SomePage.aspx" onclick="window.open(this.href, 'mynewwin', 'width=880,height=600,toolbar=0,scrollbars=1,resizable=1');return false;" >
even better would be to attach the link event in an unobtrusive manner. 更好的方法是以不引人注目的方式附加链接事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.