Saturday, August 25, 2012

Conditional Javascript in QuickLaunch bar

 

This is a great help !

The ability to display some conditional pop-ups/dialog boxes to the end-users when they click on various links on the Quick Launch bar items, seems a great idea.

I was looking to present a message to the users, whenever they clicked a certain hyper-link on the left navigation.

I wanted them to understand, that they are navigating away from their current site to a page url that might be externally hosted.

This is what really helped me do the same:

javascript: if(confirm(‘You are being re-directed to a site hosted externally. Click OK to proceed, Cancel to stay on the page.’)) document.location=’http://www.bing.com’;

Note: The above line of code being typed in a single line.

Thanks to my colleague Mike Smith for posting this trick with many other options as well.

No comments: