wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> general problem-solving / chatting / whatever >> book mark this site
(Message started by: mfirmata on Mar 28th, 2007, 9:50am)

Title: book mark this site
Post by mfirmata on Mar 28th, 2007, 9:50am
Is there html code for adding a link (or button) to my personal website so visitors can click it and it automatically creates a book mark for my site?  

I viewed the source code for the homepage for this site, and tried to mimic it, but it didn't work for me, and I figure I'm missing something.

Any help is much appreciated.
Thanks.

Title: Re: book mark this site
Post by towr on Mar 28th, 2007, 10:27am
I think the only way to do it is with javascript. I'll have a look if I can find it..

Title: Re: book mark this site
Post by towr on Mar 28th, 2007, 10:32am
Put the following in the header of your page (or anywhere, really, but it's neater to put it in the header)

<script>
function bookMark() {
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)){
window.external.AddFavorite (window.location,document.title);
}
else {
var msg = "Don't forget to bookmark us!";
if(navigator.appName == "Netscape") msg += " (CTRL-D)";
alert(msg);
}
}</script>



then make a link
<a href="javascript:bookMark();">bookmark this page</a>

It only works with IE, I think.. Thats' the problem with javascript, it varies per browser.

Title: Re: book mark this site
Post by mfirmata on Mar 28th, 2007, 6:37pm
Thanks. I'll try it out.


It works, on my laptop I use IE7 though.  

Is this what the code is doing:
- If they use IE4 or greater, it opens the favorites windows and gives them the option to add my site, or else it reminds them to bookmark the site manually.
- If they are using Netscape it opens the bookmark window, giving them the ablity to add my site.


What if they are using another browser like FoxFire or something. (Is foxfire even an internet browser?)

Thanks for your help towr.  I really appreciate it.  

Title: Re: book mark this site
Post by towr on Mar 29th, 2007, 12:00am
It opens the add-favorite dialog for IE4+. Otherwise it tells the user to do it manually, adding the suggestion CTRL-D for netscape-like browsers. (It does the latter for firefox too; it least on my computer)

I'm not sure what it does for opera or konqueror or other browsers. Possibly nothing.



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board