Welcome to WebmasterWorld Guest from 50.17.5.36

Forum Moderators: brotherhood of lan & mack

Message Too Old, No Replies

javascript - bookmark this site

     
6:07 pm on Feb 27, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 1, 2002
posts:444
votes: 0


there is this nice java script for bookmarking a site:

<SCRIPT LANGUAGE="JavaScript">
var txt = "Bookmark this site";
var url = "http://www.mydomain.com";
var who = "My Domain";

var ver = navigator.appName;
var num = parseInt(navigator.appVersion);
if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) {
document.write('<A HREF="javascript:window.external.AddFavorite(url,who);" ');
document.write('onMouseOver=" window.status=');
document.write("txt; return true ");
document.write('"onMouseOut=" window.status=');
document.write("' '; return true ");
document.write('">'+ txt + '</a>');
}else{
txt += " (Ctrl+D)";
document.write(txt);
}
</script>

and i was reading brett's successful site in 12 months and there is this point where he says it would be better not to use java script because SE spiders don't like it.

my question: how really bad is the above bookmark-java script for spiders?

[edited by: HuhuFruFru at 6:08 pm (utc) on Feb. 27, 2003]

6:08 pm on Feb 27, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 23, 2000
posts:1277
votes: 0


You could make that javascript external couldn't you?
6:09 pm on Feb 27, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 1, 2002
posts:444
votes: 0


how do i do this?
6:13 pm on Feb 27, 2003 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15755
votes: 0


put your code in a file with a js extension and then put this on the page.

<script lang="javascript" src="path_to_file.js">

[edited by: jatar_k at 6:14 pm (utc) on Feb. 27, 2003]

6:13 pm on Feb 27, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 22, 2002
posts:2546
votes: 0


<script type='text/javascript' src='/path.js'></script> :)

Man, I thought I was fast that time..not fast enough!

6:16 pm on Feb 27, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 22, 2002
posts:2546
votes: 0


Hmmm... Is my method wrong? It works on my browsers.
6:17 pm on Feb 27, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


<script type="text/javascript" language="javascript" src="/path/filename.js"></script>

You'll need the type attribute to keep the W3C HTML validator [validator.w3.org] happy, and the language attribute for really old browsers.

6:24 pm on Feb 27, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 1, 2002
posts:444
votes: 0


aahhh coool, very nice, thank you!

and when i do it external, then there is no problem with the spiders, right?

1:39 am on Feb 28, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


Most spiders cannot (yet) follow Javascript-written links, so it is best not to use Javascrit to generate code for links. Howevder this sort of Javscript is fine, whether internal (on page) or external (separate file). Having the code as external means the browser will cache the file, and you can reuse it across the whole site. Each HTML file will need only one line to call it.

You get a similar advantage for CSS by using external files for that, too.

8:14 am on Feb 28, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 1, 2002
posts:444
votes: 0


very nice g1smd, thank you :)