Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open link form different page

Status
Not open for further replies.

caconner

Technical User
May 20, 2002
42
US
When a user clicks a link on our home page, it spawns a popup informing them that they are leaving the site. Once they click the OK button, the link they originally clicked opens in the popup window.

Here's the code from the external file:
Code:
	var next_page;

function display_message(clicked_link_href)
{
	next_page = clicked_link_href;
	window.open("../scripts/speed-bump.html", "", "toolbar=yes,resizable=yes,location=yes,directories=yes,status=yes,menubar=yes,width=500,height=400,scrollbars=yes,screenX=0,screenY=0,top=0,left=0");
	return false;  //cancels onclick action so href in link doesn't load in main page
}

function next_page()
{
	window.location.href = opener.next_page; 
}

Here's the code from the originating page:
Code:
<a href="javascript:display_message('[URL unfurl="true"]http://www.ci.seattle.wa.us/')">City[/URL] 
        of Seattle</a>

And here's the popup code:
Code:
<input type="button"  class="button" value="Ok" onclick="next_page()" />

The popup opens fine, but the original link is undefined. My knowledge of js is limited, so I'm not sure if I'm passing the address correctly. Can anyone help?
 
Okay, Try this out !

Code:
<html>
<head>
<title>sample</title>

<script language="javascript">

function byebye(web_address) {
var blank = window.open()
var ask = blank.confirm("You are leaving the site")
if(ask){
blank.location = web_address
}
}
			
</script>
</head>

<body>

<a href="javascript:byebye('[URL unfurl="true"]http://www.google.com')">[/URL] Google </a>

</body>
</html>

Is this what you want?

- Jon

JavaScript Beginner at work :)
 
It does work, but I need to use a customized page and not an alert box because at some point in the future I need to code cookies so that the user can elect not to see the popup for each link.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top