How to help end users to recognize popups from being blocked in ServiceNow

General Add comments
by:

Just the other day I came across an issue with a client script, which did not seem to work in the Safari browser. The script wanted to open a browser window to register an outage using the window.open method. Turned out that this was not just related to Safari but can also be an issue with Chrome and IE, the only exception is that Safari gives you no indication of why your ‘window.open’ method is not working.

Perhaps one of the most appreciated features of Safari is its built-in Pop-Up blocker. If you’ve spent any time at all on the Web, you’re probably all too familiar with the annoying windows that pop up over and under the Web pages you’re trying to view.


Sometimes these windows contain important information, but most of the time, they’re occupied by advertisements. The pop-up blocker built into Safari is enabled by default, which bans irritating pop-up windows from your browsing experience.
Safari’s pop-up blocker works so well that you may forget that pop-up windows even exist. But sometimes it works too well. Many sites these days post warnings on their main pages stating that you may miss information if your browser employs a pop-up blocker, but if you ever come across a Web site that -doesn’t seem to be working properly (for instance, if you’re clicking a link that -doesn’t seem to be doing anything), try turning off Safari’s pop-up blocker.


Disable Pop-up Blocker by browser

Internet Explorer
In Internet Explorer, pop-up blocking is enabled by default.

Internet Explorer 7 and 8
1. Select Tools–>Pop-up Blocker–>Turn Off Pop-up Blocker.

Internet Explorer 9
1. Select Tools–>Internet Options.
2. Select the Privacy tab.
3. Uncheck Turn on Pop-up Blocker checked.

Firefox
In Firefox, pop-up blocking is enabled by default.
1. Go to the Tools menu and click on “Options
2. Click on “Content
3. To disable all popups:
• Uncheck the “Block pop-up windows” box.
4. To disable popups on just one site:
• Click on “Exceptions
• Enter the URL of the site for which you would like to allow popups
• Close the window
5. Click “Ok

Google Chrome
In Google Chrome, pop-up blocking is enabled by default.
To disable the Google Chrome pop-up blocker:
1. Click the Chrome menu on the browser toolbar.
2. Select Settings.
3. Click Show advanced settings.
4. In the “Privacy” section, click the Content settings button.
5. In the “Pop-ups” section, select “Allow all sites to show pop-ups.” Customize permissions for specific websites by clicking Manage exceptions.

Safari v 5.0.3
The pop-up blocker built into Safari is enabled by default.
1. Open Safari if it is not already open.
2. Choose Safari > Preferences, and then click Security.
3. Turn off “Block pop-up windows.”

ServiceNow and popup blocking

In ServiceNow we can help the end-user understand a bit more why our window.open method is not working.

Here is our example:

First the situation where window.open method is not blocked in ServiceNow by the built in popup blocker.
We create a UI action ‘Create Outage’ on the incident form that will execute the window.open method so that we can register an outage record for the CI stated in the incident.

[cc lang=”javascript”]
function showPopUp() {
var popup = window.open(‘cmdb_ci_outage.do?sys_id=-1&sysparm_query=u_task=’ + gel(‘sys_uniqueValue’).value + ‘^cmdb_ci=’ + g_form.getValue(‘cmdb_ci’));
}
[/cc]

This button will work in all browsers. It will open a new window/tab enabling you to create a new outage record. Popup blockers will have no effect.

Now the situation where the window.open method in ServiceNow might be blocked by the built in popup blocker.
Next we will create a client script that try to open the same outage window as above but this time when we set the ‘State’ of the incident to ‘Resolved’.

[cc lang=”javascript”]
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if(!isLoading){
if(newValue == 6 ){
window.open(‘cmdb_ci_outage.do?sys_id=-1&sysparm_query=u_task=’ + gel(‘sys_uniqueValue’).value + ‘^cmdb_ci=’ + g_form.getValue(‘cmdb_ci’));
}
}
}
[/cc]

Lets change the state of an incident to ‘Resolved’. If the built in popup blocking is enabled for your browser then no new window should have opened. When using Safari you should not even had a message/warning about a possible popup being blocked.

Lets change the code of the client script to the following.
[cc lang=”javascript”]
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if(!isLoading){
if(newValue == 6 ){
var popup = window.open(‘cmdb_ci_outage.do?sys_id=-1&sysparm_query=u_task=’ + gel(‘sys_uniqueValue’).value + ‘^cmdb_ci=’ + g_form.getValue(‘cmdb_ci’));
if (!popup) {
window.alert(‘Popup is being blocked. Check your browser settings.’ + ‘\n’ + ‘Your browser is most likely Internet Explorer, Firefox or Safari’);
return;
} else {
popup.onload = function() {
setTimeout( function() {
if (popup.outerHeight == 0) {
window.alert(‘Popup is being blocked. Check your browser settings.’ + ‘\n’ + ‘Your browser is most likely Google Chrome’);
return;
}
}, 25);
}
}
}
}
}
[/cc]
Google Chrome behaves differently then other browsers with regards to popups. Chrome actually opens the window and executes the code. Therefor we need to check for popup blocking a little differently.

If the built in popup blocking is enabled for your browser then again no new window should have opened and you should be seeing a message “Popup is being blocked. Check your browser settings.”

Chrome on Mac OSX.


Safari on Mac OSX.

Internet Explorer on Windows XP SP3.

If you have any questions you can reach me on .img[at].img.

One Response to “How to help end users to recognize popups from being blocked in ServiceNow”

  1. Herbert Azure Says:

    Now, look for “advanced” option and click on it. You may have to scroll down a little. Under the “privacy and security” options, you will find “content settings”. As you tap it, it takes you to a new list of options. You should then look up for the “pop-ups” option.

Leave a Reply