谷歌浏览器“window.open”解决方法吗? [英] Google Chrome "window.open" workaround?
问题描述
我一直在开发一个Web应用程序,并且我需要打开一个新窗口。 Chrome浏览器似乎忽略了导致我出现问题的窗口功能,我一直在努力工作。与我是否需要在新窗口中可编辑地址栏。 FF,IE,Safari和Opera做得很好,Chrome不行。
我的代码:
< script language =javascripttype =text / javascript>
<! -
function popitup(url){
newwindow = window.open(url,'name','toolbar = 1,scrollbars = 1,location = 1,statusbar = 0,菜单栏= 1,可调整大小= 1,宽度= 800,高度= 600' );
if(window.focus){newwindow.focus()}
return false;
}
// - >
< / script>
任何帮助都会被感激地收到!在此先感谢:)
其他答案已过时。 Chrome对 window.open
的行为取决于它从哪里调用。另请参阅此主题。
$ b $ <
< a target =_ blank>
,默认情况下会在新标签中打开。然而,如果在其他地方调用 window.open
,Chrome会忽略其他参数,并始终打开一个带有不可编辑地址栏的新窗口。 这看起来像是某种安全措施,但背后的理由还不完全清楚。
I have been working on a web app and for part of it I need to open a new window. I have this working on all browsers, my sticking point is with Google Chrome.
Chrome seems to ignore the window features which is causing me issues, the thing I'm struggling with is I need the address bar to be editable within the new window. FF, IE, Safari and Opera do this fine, Chrome does not.
My Code:
<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
newwindow=window.open(url,'name','toolbar=1,scrollbars=1,location=1,statusbar=0,menubar=1,resizable=1,width=800,height=600');
if (window.focus) {newwindow.focus()}
return false;
}
// -->
</script>
Any help would be gratefully received! Thanks in advance :)
The other answers are outdated. The behavior of Chrome for window.open
depends on where it is called from. See also this topic.
When window.open
is called from a handler that was triggered though a user action (e.g. onclick event), it will behave similar as <a target="_blank">
, which by default opens in a new tab. However if window.open
is called elsewhere, Chrome ignores other arguments and always opens a new window with a non-editable address bar.
This looks like some kind of security measure, although the rationale behind it is not completely clear.
这篇关于谷歌浏览器“window.open”解决方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!