Issue:
When you invoke following JS codes in original page,
| 1 | ahref="javascript:window.open('child.html');"> |
you can open child.html inside a new widow, but original page will loads following text instead of original content.
| 1 | text[objectwindow] |
Reason:
This problem is caused by the return value of Open function.
Solution:
Set ‘void’ as the return type of open function in mandatorily.
| 1 | ahref="javascript:void(window.open('child.html'));"> |
本文介绍了一个JavaScript编程中常见的问题:当使用window.open()方法在一个新的窗口打开链接时,原始页面的内容被替换为[object Window]字符串。文章详细解释了这个问题的原因,并提供了解决方案——通过设置return void来避免该问题。

被折叠的 条评论
为什么被折叠?



