PDA

View Full Version : Need Help Hiding Javascript



leanbike
12-15-2003, 04:15 PM
Brendon Turner, Senior SEO Consultant with eTrafficJams.com wrote (Dec.15 Issue #422)in sitepronews.com :

Search engine spiders cannot read Javascript and it is possible that along with ignoring it when they come across it on your page, they may also get hung up on it if you are using a lot of it......you can safely use it by putting the code into a separate JS file and calling it with a single line of code which you place between your <head> and </head> tags within your web page. The code used to include your JS file looks like this:
<SCRIPT LANGUAGE="JavaScript" type="text/javascript"
src="replace-with-JavaScript-file-name.js"></SCRIPT>

Question: So i create a file JS, place it on my server in the public.html? I'm guessing that the java script to be ref. is not on a .htm page. so i could use some additional info,
thanks, you guys are great.

andyholt
12-15-2003, 07:14 PM
Hi

When you create your javascript you put all your functions etc in 1 page and give it a .js extension for example
windowopener.js

Your external javascript file should not include any <script></script> tags. Adding the tags will generate errors.

when you write yourfile.js it should look similar to this


function somefunction(){
//some code
}

No script tags :)

You link to it as described in your post. .js links are ignored by the search engines. Using external scripts also reduces your document weight (if the script is reused on many pages)

Hope that helps

Andy

leanbike
12-16-2003, 10:30 AM
hay, thanks andy.
your help is much appreciated.
dieter

leanbike
12-16-2003, 12:10 PM
Code:
function somefunction(){
//some code
}

i created inco.js file, uploaded it with the javascripts minus the script tags. ref. the js file via the java in the referring page
it looks like i am missing the: function() portion of the above format in the js file.

(drbackman.com/default same as drbackman.com minus the js file referral)
www.drbackman.com/Default.htmwww.drbackman.com/inco.js

paulhiles
12-16-2003, 01:07 PM
I'm guessing that the java script to be ref. is not on a .htm page. so i could use some additional info
Hi Lawrence,

the actual name of your JavaScript file needs to be referenced in the head section of your page.
Currently you have this in your Default.htm page:

<SCRIPT LANGUAGE="JavaScript" type="text/javascript" src="replace-with-JavaScript-file-inco.js"></SCRIPT>
When what you actually need is this:

<SCRIPT LANGUAGE="JavaScript" type="text/javascript" src="inco.js"></SCRIPT>

Hope that helps! ;-)

Paul

leanbike
12-17-2003, 12:57 AM
thanks paul and andy,
of course,......all is working perfect.

"knowledge is like money, its no object when you have it."