如何修改此小书签以在选项卡而不是新窗口上工作?
当你把它放在浏览器中时,它会打开一个简单的记事本来输入。
我对 javascript 不太了解,无法更改它,但我想让它不会在新窗口中打开,而是在当前窗口中打开或另一个选项卡。
这可能吗?
javascript:pwin=window.open('','_blank','menubar=yes,scrollbars=yes,location=no,height=450,width=350');pwin.document.body.contentEditable='true';pwin.document.designMode='on';void(0);if(window.focus){pwin.focus()};
When you put this in your browser it opens a simple notepad to type in.
I don't know enough about javascript to alter it but I would like to make it so it DOESN'T open in a new window but rather in the current window or another tab.
Is this even possible?
javascript:pwin=window.open('','_blank','menubar=yes,scrollbars=yes,location=no,height=450,width=350');pwin.document.body.contentEditable='true';pwin.document.designMode='on';void(0);if(window.focus){pwin.focus()};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
从技术上讲,
window.open
并不总是在新窗口中打开。您可以使用_self
代替_blank
,它将在同一窗口中打开。或者使用_parent
,它将在当前框架的父框架中打开。Technically,
window.open
does not always open in a new window. You can use_self
instead of_blank
, and it will open in the same window. Or use_parent
and it will open in the current frame's parent.Window.open
始终在新窗口中打开它。相反,我认为你可以尝试
window.location
。没有努力过。Window.open
always opens this in a new window.Instead I think you can try
window.location
. Not tried tough.好吧,做了一些挖掘,但您无法保证它将在新选项卡中打开。但是,如果您删除宽度和高度参数,并且用户首选项没有覆盖此行为,某些浏览器将在新选项卡中打开。请参阅这篇文章(列表中的第二个答案)Stackoverflow 帖子
Ok did a little digging and there is nothing you can do that will guarantee that it will open in a new tab. However if you remove the width and height parameters some browsers will open in a new tab if user preferences haven't overridden this behavior. See this post (2nd answer in list) Stackoverflow post
如果您不想打开窗口,那么不要使用 window.open()
设置 window.location 应该可以解决问题,正如 Sachin 所指出的
If you aren't looking to open a window, then don't window.open()
Setting window.location should do the trick, as pointed out by Sachin