Welcome to WebmasterWorld Guest from 54.226.147.190

Forum Moderators: brotherhood of lan & mack

Message Too Old, No Replies

javascript - bookmark this site

     

HuhuFruFru

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

10+ Year Member



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]

JamesR

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

WebmasterWorld Senior Member 10+ Year Member



You could make that javascript external couldn't you?

HuhuFruFru

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

10+ Year Member



how do i do this?

jatar_k

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

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



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]

Birdman

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

WebmasterWorld Senior Member 10+ Year Member



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

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

Birdman

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

WebmasterWorld Senior Member 10+ Year Member



Hmmm... Is my method wrong? It works on my browsers.

g1smd

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

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



<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.

HuhuFruFru

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

10+ Year Member



aahhh coool, very nice, thank you!

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

g1smd

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

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



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.

HuhuFruFru

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

10+ Year Member



very nice g1smd, thank you :)
 

Featured Threads

Hot Threads This Week

Hot Threads This Month