Bookmark on exit

They have: 19 posts

Joined: Sep 2007

help me please, i need a script or code that will ask the user if they want to add the page to their favourites upon clicking the x in the top right corner. any suggestions please

He has: 629 posts

Joined: May 2007

You could do that with a script that runs on window.onunload, assuming the visitor's browser allows scripts to add bookmarks.

I don't have a script handy to do that, though. Sad

Cordially, David
--
delete from internet where user_agent="MSIE" and version < 8;

They have: 19 posts

Joined: Sep 2007

webwiz;223738 wrote: You could do that with a script that runs on window.onunload, assuming the visitor's browser allows scripts to add bookmarks.

I don't have a script handy to do that, though. Sad

if anyone else can expand i would be grateful

cwboaze's picture

He has: 4 posts

Joined: Aug 2007

ok, here you go.

The Javascript code, add this to the page you want to on close warn about bookmarking the site. ok!

place this code before you body tag, in the header.

&lt;script type="text/javascript"&gt;
function bookmarksite(title,url){
if (window.sidebar)
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all)// ie
window.external.AddFavorite(url, title);
}
&lt;/script&gt;
'

then add this to your body tag:

onUnload="javascript:bookmarksite('YOURWEBSITETITLE', 'YOURWEBSITEURL')"'

so your body tag should look like this;

<body onUnload="javascript:bookmarksite('YOURWEBSITETITLE', 'YOURWEBSITEURL')">'

cwboaze's picture

He has: 4 posts

Joined: Aug 2007

forgot to add, to edit this. Add your site title and site url in place of the following text in the body code.

YOURWEBSITEURL and YOURWEBSITETITTLE

I figured you would notice since I put it in like that.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.