在 chrome 下弹出一个窗口

2022-01-20 00:00:00 google-chrome popup javascript

我有一个按钮需要打开一个新窗口作为弹出窗口(在父页面下).在 IE/Firefox 中,它可以正常工作,但在 chrome 中,弹出窗口出现在父窗口上方(顶部).

I have a button that needs to open a new window as a popup (under the parent page). In IE/Firefox, it works fine, but in chrome the popup appears over (on top of) the parent window.

请提出修复建议.

用例/例如:好吧,例如,如果您看到 kayak.com 或任何旅游网站,您也可以在其他网站上搜索..我想做类似的事情,所以需要弹出...

use case/eg: Well, for eg if you see kayak.com or any travel website, you have the ability to search on other websites too..I want to do something similar so need the pop under...

代码:我使用的是 window.open(.......).blur(),但由于某种原因它不能在 chrome 中工作.

Code: I am using a window.open(.......).blur(), but for some reason it isnt working in chrome.

推荐答案

我收回我的评论,是可能的.

I take back my comment, is possible.

以下内容对我有用.(测试了最新的生产 chrome)

The following worked for me. (tested latest production chrome)

var url = "yourURL.html";
window.open(url, "s", "width= 640, height= 480, left=0, top=0, resizable=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no").blur();
window.focus();

像所有事情一样,如果您惹恼了访问者,您的访问者就会减少.

Like all things, if you annoy your visitors you will have less visitors.

相关文章