Several websites rely on the ever-so-annoying popup window. As much as well all hate popup windows, some websites do benefit and justly require them. The problem is that some people have their popup blocker on but don't know it -- thus the new window doesn't open. Of course the browser notifies the user but it isn't always as obvious as it should be. Here's a quick method for testing if your popup window is being blocked.
一些网站依赖于如此烦人的弹出窗口。 就像所有讨厌的弹出窗口一样,有些网站确实受益并公平地需要它们。 问题是有些人打开了弹出窗口阻止程序,但不知道该阻止程序-因此不会打开新窗口。 当然,浏览器会通知用户,但并不总是那么明显。 这是一种测试弹出窗口是否被阻止的快速方法。
JavaScript (The JavaScript)
var windowName = 'userConsole';
var popUp = window.open('/popup-page.php', windowName, 'width=1000, height=700, left=24, top=24, scrollbars, resizable');
if (popUp == null || typeof(popUp)=='undefined') {
alert('Please disable your pop-up blocker and click the "Open" link again.');
}
else {
popUp.focus();
}
The first step is to give the directive to open a new window, saving what's returned. Then we check to see if the object exists. If it does, we're good. If it doesn't, we give an alert to the user that their popup blocker may be on. The specific text warning can be set to whatever you'd like, as could the method of giving them the message. You could also use a sexy MooTools slider to show the message.
第一步是给指令打开一个新窗口,保存返回的内容。 然后我们检查对象是否存在。 如果可以,那么我们很好。 如果不是,我们会向用户发出警报,告知他们的弹出窗口阻止程序可能已启用。 可以将特定的文本警告设置为您想要的任何内容,也可以将其设置为向他们发送消息的方法。 您也可以使用性感的MooTools滑块显示消息。