1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Very simple javascript question

Discussion in 'HTML & Website Design' started by fryman, Apr 17, 2005.

  1. #1
    I have this code on my page:

    This is directly on my page, I want to have it called from an external javascript file, can someone tell me how would I do this? (bear in mind that I almost have no knowledge of web coding)

    Thanks
     
    fryman, Apr 17, 2005 IP
  2. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #2
    Simple task driving me crazy, come on, I know this is something anyone (except me) knows how to do
     
    fryman, Apr 17, 2005 IP
  3. TommyD

    TommyD Peon

    Messages:
    1,397
    Likes Received:
    76
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It looks like it is an external file being called. :confused:
     
    TommyD, Apr 17, 2005 IP
  4. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #4
    What I mean is instead of having this code on my page, I want it to call another javascript file on a different folder, for example, gateway.js
    Something like
    <script language="Javascript" type="text/javascript" src="gateway.js">
    </script>

    But I can't make it work
     
    fryman, Apr 17, 2005 IP
  5. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The way you use it, gateway.js is supposed to be in the same directory as the file that inclides this statement. If you want any page load it use this:

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

    J.D.
     
    J.D., Apr 17, 2005 IP
  6. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #6
    fryman, Apr 17, 2005 IP
  7. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Where's the script located (relative to the web root)?
     
    J.D., Apr 17, 2005 IP
  8. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #8
    That shouldn't be a problem, I used the complete address to call the script (<script language="Javascript" src="http://www.mysite.com/gateway.js">
    </script>)

    What would be the correct thing to put inside the .js file, JD?
     
    fryman, Apr 17, 2005 IP
  9. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Just JS - no HTML
     
    J.D., Apr 17, 2005 IP
  10. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #10
    I am back to where I started now.

    OK, this is my original code

    I want to get rid of that code that is currently on my page and have it on an external javascript file called gateway.js

    So...

    Would this be correct to have on my page?
    And, if that is correct, what exactly would I need to put inside the gateway.js file?

    The reason I need to have this .js file on a separate folder is that It is messing completely my site, it is a gateway that is also blocking the spider from indexing my pages, so I want to put it in a folder, disallow the spiders from visiting that folder, and forget about the stupid script and get my pages back, I have lost over 3,000 pages thanks to this.
     
    fryman, Apr 17, 2005 IP
  11. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Save the JS code returned by your original URL (the one with .aspx) as gateway.js - this is your content.

    Put this file into any directory on your website or any other website - it doesn't matter where you store it.

    Add either of these statements to your page (pick the right one depending on where the script is located):

    <script type="text/javascript" src="/gateway.js"></script>
    <script type="text/javascript" src="/dir/dir/gateway.js"></script>
    <script type="text/javascript" src="http: //www. site.com/dir/dir/gateway.js"></script>

    J.D.
     
    J.D., Apr 17, 2005 IP
  12. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #12
    I have no problems with the second part, it is the first one where I'm stuck. What exacly goes in the gateway.js file, is it


    or just I have no idea what you mean with "JS code returned by your original URL "
     
    fryman, Apr 17, 2005 IP
  13. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #13
    http://www.somesite.com/gateway.aspx?productid=4xxx&val=2xxx19

    should return you JavaScript code. In fact, if you type it in the browser, you will see this code. Save this page as gateway.js. If you want, PM me the actual URL.
     
    J.D., Apr 17, 2005 IP
  14. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #14
    I think I now understand what I need to do, but I wonder if this will affect the tracking. I sent you a PM, let me know what you think

    Thanks!
     
    fryman, Apr 17, 2005 IP