+ Reply to Thread
Results 1 to 7 of 7

Thread: javascript and external javascript files problem

  1. #1
    delon is offline Banned delon is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Hindustan
    Posts
    397

    Exclamation javascript and external javascript files problem

    i signed up at adbrite.com and got an ad code for my website ( written in javascript ). i dont want to use the javascript code in my source code but use it at as an external .js file. in my source code i entered this javascript in my source code :
    <script src="http://www.delon.in/ads/leaderboard.js"></script>

    and saved the code in file in leaderboard.js at http://www.delon.in/ads/leaderboard.js. but i cannot view the ads on my website. i saw at w3schools.com that the external javascript file should not have <script></script> tags. i tried editing the code but of no use. it would be great if someone could edit the original ad code so it can run through the external .js file.

    original ad code by adbrite ( written in javascript ) :
    <!-- Begin: AdBrite -->
    <script type="text/javascript">
    var AdBrite_Title_Color = '660000';
    var AdBrite_Text_Color = '000000';
    var AdBrite_Background_Color = 'FFCC66';
    var AdBrite_Border_Color = '660000';
    var AdBrite_URL_Color = '008000';
    </script>
    <span style="white-space:nowrap;"><script src="http://ads.adbrite.com/mb/text_group.php?sid=658305&zs=3732385f3930" type="text/javascript"></script><!--
    --><a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=658305&afsid=1"><img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-leaderboard-w.gif" style="background-color:#660000;border:none;padding:0;margin:0;" alt="Your Ad Here" width="14" height="90" border="0" /></a></span>
    <!-- End: AdBrite -->

    please help me, im totally a newbie at programming.

  2. #2
    LHVWB's Avatar
    LHVWB is offline Lord Of The Keys LHVWB is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Australia
    Posts
    1,308

    Re: javascript and external javascript files problem

    Okay, the code that you have copied into the .js file is actually html code with a javascript tag that has javascript inside it.

    Notice the <script> html tags which are for the javascript and the <a> and <span> html tags which show their actual adds.

    The way that this add has been setup by adbrite, you have to copy that code directly into the page that you want to show it in. That will make it work.

    Javascript files cannont contain anything but javascript, so that is why putting the html into is was stopping it from working.
    Last edited by LHVWB; 04-26-2008 at 01:40 AM.

  3. #3
    delon is offline Banned delon is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Hindustan
    Posts
    397

    Re: javascript and external javascript files problem

    so is there any way in which i can the code in a file and link it to the page so that i when i have to edit the ad code then i wont need to edit all the pages containing that particular code.

  4. #4
    lszanto is offline x10Hosting Member lszanto is an unknown quantity at this point
    Join Date
    Apr 2008
    Posts
    23

    Re: javascript and external javascript files problem

    If you have php enabled on the site you are trying to do this on you can simple replace the .html at the end and put a .php and then the following will work.

    Instead of using <script src="thescript.js" ></script> you can add <?php include "ads.inc"; ?>

    And then in the same directory just add this file as ads.inc(it doesn't really matter what extension you give the file, as long as it matches.
    Code:
    <!-- Begin: AdBrite -->
    <script type="text/javascript">
    var AdBrite_Title_Color = '660000';
    var AdBrite_Text_Color = '000000';
    var AdBrite_Background_Color = 'FFCC66';
    var AdBrite_Border_Color = '660000';
    var AdBrite_URL_Color = '008000';
    </script>
    <span style="white-space:nowrap;"><script src="http://ads.adbrite.com/mb/text_group.php?sid=658305&zs=3732385f3930" type="text/javascript"></script><!--
    --><a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=658305&afsid=1"><img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-leaderboard-w.gif" style="background-color:#660000;border:none;padding:0;margin:0;" alt="Your Ad Here" width="14" height="90" border="0" /></a></span>
    <!-- End: AdBrite -->
    Or you could just put that html/javascript in the original website, your choice.
    Do you understand?
    Last edited by lszanto; 04-26-2008 at 03:21 AM.

  5. #5
    delon is offline Banned delon is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Hindustan
    Posts
    397

    Re: javascript and external javascript files problem

    thanxxxxx, then i also would have to change the extension of my main page to .php ?
    Last edited by delon; 04-26-2008 at 03:33 AM.

  6. #6
    LHVWB's Avatar
    LHVWB is offline Lord Of The Keys LHVWB is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Australia
    Posts
    1,308

    Re: javascript and external javascript files problem

    Yes, the main page which is going to show the add would have to be a .php page, while the file with the add code in it could be a .html or a .php or a few other types.

  7. #7
    delon is offline Banned delon is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Hindustan
    Posts
    397

    Re: javascript and external javascript files problem

    thanks for the help, x10hosting roxx

+ Reply to Thread

Similar Threads

  1. javascript external files
    By delon in forum Free Hosting
    Replies: 1
    Last Post: 04-25-2008, 10:19 AM
  2. JavaScript help!
    By disturbedart in forum Programming Help
    Replies: 5
    Last Post: 01-17-2008, 06:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers