View Full Version : Leaving website alert help


hitchhiker
24-06-2006, 18:31
Is there a simple way to create a pop-up or alert possibly similar to the javascript alert when someone clicks on an external link to say something along the lines of:

'You are now leaving this website. Click OK to proceed or Cancel to go back.'

I've been so far unable to find anything to do this.

Any help would be much appreciated

maggi
24-06-2006, 19:19
In your head tags include a script with



function pleaseDontGo(newSite) {
if(confirm('You are now leaving this website. Click OK to proceed or Cancel to go back.')) {
location.href = newSite;
}
return false;
}


On the link


<a href="http://www.sheffieldforum.com/" onClick="return pleaseDontGo('http://www.sheffieldforum.com/')">

hitchhiker
24-06-2006, 19:38
Only one small hitch...

Thanks - it works perfectly but it needs to open in a new window.

How do I do that???

hitchhiker
25-06-2006, 13:19
Someone must be able to help???

esme
25-06-2006, 13:23
use

<a href="http://www.sheffieldforum.com/" target="_blank" onClick="return pleaseDontGo('http://www.sheffieldforum.com/')">

hitchhiker
25-06-2006, 14:14
use

<a href="http://www.sheffieldforum.com/" target="_blank" onClick="return pleaseDontGo('http://www.sheffieldforum.com/')">

That doesn't work!

esme
25-06-2006, 15:31
Doh! course it won't the script is going to open the window isn't it, just slap me :blush:

script needs to be

function pleaseDontGo( newSite ) {
if ( window.confirm( 'You are now leaving this website. Click OK to proceed or Cancel to go back.' ) ) {
window.open( newSite );
}
return false;
}


and link needs to be

<a href="" onclick="return pleaseDontGo('http://www.sheffieldforum.com/')">test
link
</a>

the script is going to override the href so there's no point having it there really, hence the null string

hitchhiker
26-06-2006, 10:13
Working fine except for.....

It's getting stopped by pop-up blocking software now!!!! :help:

esme
26-06-2006, 10:51
can you set your pop up blocker to allow pop ups from that site ?

sadly you won't be able to do this for other visitors to your site as that would defeat the object of a pop up blocker, maybe you can put a note on the page somewhere saying pop ups need to be allowed for the site to work

hitchhiker
26-06-2006, 11:05
can you set your pop up blocker to allow pop ups from that site ?

sadly you won't be able to do this for other visitors to your site as that would defeat the object of a pop up blocker, maybe you can put a note on the page somewhere saying pop ups need to be allowed for the site to work

Thanks or the help.

The reason it needs to have an exit message is because the company whose website this is are regulated by the FSA and therfore need to distinguish between their site's content and external sites they link to.

The first thing I thought was just have a note explaining that '...accepts no responsibility for the availability or content on any site to which a hypertext link from this site exists...etc.' however, this is not acceptable just as my second option of using an alert as you enter the links page is not acceptable either.

Asking site visitors to turn off their pop-up blocking software is also not an option.

esme
26-06-2006, 11:15
well to get round the pop up blocker problem you need to open in the same window so I would suggest that you try something like having each link to an external site be a small webform containing a hidden field with the target url on it and the link the user clicks on acting as the submit button, this goes to an intermediate page that does the confirmation, if confirmation is successful the user gets to the target page otherwise you return via a back button emulation to where you were

bit laborious and takes you briefly off the main site but avoids the pop up blocker issue

Nazo
26-06-2006, 11:19
HSBC doesn't do that and I'd assume they would be bound by the same guidelines. They just have a clause in their T&C about not being responsible blah blah...

Couldn't you use the title tag in your link to show a tool tip saying that the link goes to an external site?

hitchhiker
26-06-2006, 11:52
well to get round the pop up blocker problem you need to open in the same window so I would suggest that you try something like having each link to an external site be a small webform containing a hidden field with the target url on it and the link the user clicks on acting as the submit button, this goes to an intermediate page that does the confirmation, if confirmation is successful the user gets to the target page otherwise you return via a back button emulation to where you were

I was thinking I'm going to have to use an intermediate page but as I asked in the inital post: 'Is there a simple way...'

Suppose I'm just being lazy!

My biggest problem is the way I designed the site in the first place: Because of the layout and images and the fact that no CMS is needed I decided to use frames as opposed to the php 'include' command. I never usually use them however as the search engine's get more sophisticated there's no longer a problem with the site indexing properly so I thought 'what the hell'.

HSBC doesn't do that and I'd assume they would be bound by the same guidelines. They just have a clause in their T&C about not being responsible blah blah...

They are no the same type of financial institution and as I'm not an expert in that field, I wouldn't like to argue the point.