Computer Hope

Internet & Networking => Web design => Topic started by: PL2007 on January 13, 2007, 03:19:24 AM

Title: Would u like 2 add me 2 favourites before you go?
Post by: PL2007 on January 13, 2007, 03:19:24 AM
Hi,
Here is a completely new one on me, but I'm hoping someone can help me.

If a user clicks on the X (top right) to close or types a new address into the address bar etc. but is leaving the site completely in any case, is it possible for them to get a quick IE box asking if they would like to save the site to their favourites before they go. Then they get a yes/no option. If they click on yes the site should go straight to favourites and they can carry on going to wherever they were going.

Is that possible with HTML, PHP or whatever?
Title: Re: Would u like 2 add me 2 favourites before you
Post by: fffreak on January 13, 2007, 09:16:10 PM
Not that I know of, You see my thoughts toward that is complete laziness as it is right there in front of you all you have to do is click the favorites tab, and click add to favorites. You could try designing your own browser and put a command in there...onClose do add favorites(Not a real method in programming), and of course you will have alot of security issues. ;)
Title: Re: Would u like 2 add me 2 favourites before you
Post by: Dilbert on January 13, 2007, 09:43:25 PM
Another option is to have a JavaScript popup in the OnUnload() event of your site, which is an HTML page that asks with a Yes or No button. I must warn you, however, that your visitors will not love you for it, and it tends to scare away traffic.
Title: Re: Would u like 2 add me 2 favourites before you
Post by: fffreak on January 13, 2007, 09:57:19 PM
My mistake is he trying to make a website that does that? This (http://www.webdevelopersnotes.com/tips/html/creating_add_to_favorites_link_script.php3) would be your best bet. ;D Sorry for misunderstanding as you didn't say it was for one of your sites.
Title: Re: Would u like 2 add me 2 favourites before you
Post by: fffreak on January 14, 2007, 12:23:36 AM
I have found your anser...How much will you pay me? JK LOL ;D.
Here ya go...

Quote
(Your HTML code)
<html>
<head>
<title>
</title>
</head>
<body>
<noscript>Please Enable Javascript</noscript>
</body>
</html>

[highlight]<script language=Javascript>
window.onunload = function(){
var urlAddress = "http://www.yourdomain.com/bookmark.html";
var pageName = "Your page name";
var answer = confirm("Add to favorites before you go?")
      if (answer){
         window.external.AddFavorite(urlAddress,pageName)
      }
      else{
            alert("Bye.")
      }
};
</script>[/highlight]
Put that below your HTML code.

EDIT: One more thing about this script everytime the page is closing or your are visiting another page the alert will pop up, so it would be an annoyance.
Title: Re: Would u like 2 add me 2 favourites before you
Post by: Rob Pomeroy on January 14, 2007, 10:20:56 AM
Browser support for this javascript is variable.  If a website did that to me, I would never visit it again.
Title: Re: Would u like 2 add me 2 favourites before you
Post by: fffreak on January 14, 2007, 06:55:19 PM
I know I thought I would just throw that in there though, because he may have other scripts that he may also want to run.