Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Linking to file.js for ads

    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:

    Code:
    <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:

    Code:
    <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.
    Last edited by ebay258; 04-10-2005 at 09:48 PM.

  • #2
    Regular Coder
    Join Date
    Nov 2003
    Location
    Vancouver Island Canada
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What's in your .js file?

  • #3
    Registered User
    Join Date
    Dec 2004
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by glenmac
    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.

  • #4
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts

    this should help

    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.

  • #5
    Registered User
    Join Date
    Dec 2004
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #6
    Registered User
    Join Date
    Dec 2004
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Anybody?

  • #7
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    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>";


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •