...

View Full Version : Linking to file.js for ads



ebay258
04-10-2005, 09:45 PM
I want to decrease the size of my page and increase loading time by placing my banner ads on a differentr page then link to them like this:


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

<script src="filename.js" type="text/javascript" lang="javascript"></script>
I use css so I did this for left banner:


<div class="left">
<script language="Javascript" src="http://www.freewebs.com/whosting/leftbanner.js"> </script></div>

...but it didn't work. What am I doing wrong? Thanks in advance.

glenmac
04-10-2005, 09:50 PM
What's in your .js file?

ebay258
04-11-2005, 12:55 AM
What's in your .js file?

It's the javascript for a 120x600 ad banner.

You can see it here: http://www.freewebs.com/whosting/leftbanner.js

I tried it like this:
<div class="left"><script language="Javascript" src="http://www.freewebs.com/whosting/leftbanner.js"> </script></div>

...but it wouldn't work.

brandonH
04-11-2005, 03:27 AM
ok first off , when using an external javascript file (.js) you do not include the "<script> and </script>" tags in the .js file. it will cause an error or not work. second there are two ways to add in things such as ad banners with javascript. one is to do so:

<div>
<script language=javascript>
document.write('what it is you are inserting');
</script>
</div>

second is to do so:

inside you external .js file you must specify a certain area inwhich to insert html.

//this is part of your external .js file
document.getElementById('div1').innerHTML="what you want to insert";
//end external file

<div id=div1></div>


with the above you do not need to insert <script> tags into the source code in certain spots. it'll find the <div> with the id value of 'div1' and insert what you want it to.

ebay258
04-11-2005, 04:39 AM
I tried the second one but it did not work. Can you please explain it more specifficaly?


The external .js: http://www.freewebs.com/whosting/leftbanner.js

Did I get the external .js right? (the red part is my ad code).

//this is part of your external .js file
document.getElementById('div1').innerHTML="<!-- Tag for size 120 x 600 for site mn-finance.com: Run-of-site - DO NOT MODIFY -->
<SCRIPT TYPE="text/javascript" SRC="http://ad.yieldmanager.com/rmtag2.js"></SCRIPT>
<SCRIPT language="JavaScript">
var rm_host = "http://ad.yieldmanager.com";
var rm_section_id = 3077;
var rm_iframe_tags = 1;

rmShowAd("120x600");
</SCRIPT>
<!-- End of tag -->
";
//end external file


Then do I just put, <div id=div1></div> in my html?

ebay258
04-11-2005, 08:30 AM
Anybody?

brandonH
04-11-2005, 12:05 PM
you do not want to insert the actual script into the <div> just the content the script creates. so you will porbably have to modify your script to create a suitable output.
also when using innerHTML you must make sure that all quotes inside are passed with a "\" infront of them or the script will think that the quote is part of the script. example:

document.getElementById('div1').innerHTML="<a href=\"location.html\">click here</a>";



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum