Welcome to WebmasterWorld Guest from 54.147.0.174

Forum Moderators: open

Message Too Old, No Replies

Help Please :::: External .JS File

     

NeedScripts

4:26 am on Oct 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am wanting to use external.js file for banner code, however, I am not able to make it work.

1) There are tons of category on the site (site on profile).
2) I would like to make a sub dir under root, called /jsfiles/
3) I have heard at WebmasterWorld that absolute link cannot be used but I found couple sites, that says something different [ (a) [javascript-fx.com...] & (b) [html4me.com...] ]

I was wondering, if you I can get some suggestion, on how I can use absolute path to external.js for below code


<script language='JavaScript' type='text/javascript'>
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://ads.needscripts.com/adjs.php?n=aa2d578c");
document.write ("&amp;what=zone:29");
document.write ("&amp;exclude=" + document.phpAds_used);
document.write ("'><" + "/script>");
//-->
</script><noscript><a href='http://ads.needscripts.com/adclick.php?n=aa2d578c'><img src='http://ads.needscripts.com/adview.php?what=zone:29&amp;n=aa2d578c' border='0' alt=''></a></noscript>

Thanks for the help.

maccas

4:50 am on Oct 22, 2002 (gmt 0)

10+ Year Member



Wow twice in one day :)

Put <script src="/jsfiles/ads.js">
</script> in head and put everything between <script language='JavaScript' type='text/javascript'> and </script> (not those tags) in /jsfiles/ads.js

NeedScripts

5:12 am on Oct 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Put <script src="/jsfiles/ads.js"> </script> in head

Sorry for another stupid question.

Suppose I put <script src="http://www.domain.com/jsfiles/ads.js"> </script> in head, but how will the banner show up on the differnt part of page?

And when you say put everything in /jsfiles/ads.js file, with everything you mean


<script language='JavaScript' type='text/javascript'>
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://ads.needscripts.com/adjs.php?n=aa2d578c");
document.write ("&amp;what=zone:29");
document.write ("&amp;exclude=" + document.phpAds_used);
document.write ("'><" + "/script>");
//-->
</script><noscript><a href='http://ads.needscripts.com/adclick.php?n=aa2d578c'><img src='http://ads.needscripts.com/adview.php?what=zone:29&amp;n=aa2d578c' border='0' alt=''></a></noscript>

right?

maccas

5:25 am on Oct 22, 2002 (gmt 0)

10+ Year Member



Oh sorry not in the head, where ever you want your banner to appear. Yeah you can use <script src="http://www.domain.com/jsfiles/ads.js"> </script> I would use /jsfiles/ads.js just in case in the future you decide to change domain names, it dosn't matter if you have a page at /a/b/c/d/ or /a/ the slash at the start means relative to root. No do not put <script language='JavaScript' type='text/javascript'> and</script> in your external file, that is most likely why you are getting a error. I am not sure about the noscript tag maybe you could use SSI to add the code.

NeedScripts

5:42 am on Oct 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am not sure about the noscript tag maybe you could use SSI to add the code.

Hey, that was the problem, I tried tons of tricks but nothing worked, however, lastly after reading your post, I tried removing the noscript tag and *boom*, it worked.

Now another problem. Is there a way, I can also include the SSI tag or noscript in the ads.js file? cuz, it would be super boring to create two files (one ssi and other .js) for every banner.

NeedScripts

6:08 am on Oct 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



By the way, one more question.

I have heard that using JavaScript on the website increases the load time, now if I were to use .js file, would the load time be changed any? (hopefully reduced?)

Reflect

11:49 am on Oct 22, 2002 (gmt 0)

10+ Year Member



I have heard that using JavaScript on the website increases the load time, now if I were to use .js file, would the load time be changed any?

I don't think external JS is cached, I could be wrong. However a plus is the spiders will bypass the external JS and this will in turn push your content closer up to the <body> tag.

Brian

g1smd

11:49 pm on Oct 23, 2002 (gmt 0)

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




If you are using the same external .js file on several HTML pages, then page loading will be faster as the .js file is cached in the browser.

Don't forget to include the type="text/javascript" and the language="javascript" attributes within the script tag.

Note that script tags can go within the head or body, but noscript tags must only go in the body section of an HTML document.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month