[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Leaving Website Alert Box

Posted on 2011-02-10
5
Medium Priority
?
635 Views
Last Modified: 2012-05-11
On our corporate site we need to have links that are external to our company come up with an Alert Box stating they are leaving the site.  If they choose continue it will allow them to go to that link but if they cancel it will go back to the exisitng web page.  I am unsure of how to do this and want to see if anyone can help create a script that can accomplish this task.  
0
Comment
Question by:CVNetworks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 34868232
Check this :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script language="javascript">
	$(document).ready(function() {
		$("a").click(function(e) {
			var url = $(this).attr("href");
			if( url.toLowerCase().indexOf("http") == 0 ) {
				e.preventDefault();
				if( confirm("Do you really want to left our site?") ) {
					location.href = url;
				}
			}
		});
	});
</script>
</head>
<body>
<a href="http://www.google.com">Outside</a><br />
<a href="/page2.html">Inside</a>
</body>
</html>

Open in new window

0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 34868233
javascript has onunload event for body, but using this you cannot return to the web-page since that event is called after the page is unloaded.

javascript also has onbeforeunload event, which is called before unloading happens, but it works only on IE.

So, i don't think there is any way to achieve your requirement
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 34868241
ohh...k

I was thinking if you are asking to show that prompt when user clicks on browser's close button... My bad
0
 
LVL 2

Expert Comment

by:Nicholas Ford
ID: 34868245
Take a look at this script, I think it will do what you want.
0
 

Author Closing Comment

by:CVNetworks
ID: 34868263
This is exactly what I was looking for.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question