justuptime.com - monitor your servers & websites

Bookmark on exit

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

They have: 23 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: 343 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
--
"Old web developers don't die, they degrade gracefully..."

They have: 23 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.

<script type="text/javascript">
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);
}
</script>

'

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.