using onclick() to call remote .js file?

Discussion in 'JavaScript' started by travisbishop, Oct 31, 2007.

  1. #1
    I have a remote .js file that I want to call with an onclick() event handler. Is this possible or am I wasting my time?
     
    travisbishop, Oct 31, 2007 IP
  2. ezpz

    ezpz Peon

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    In the header, put

    <script src="http://yoursite.com/remote.js" type="text/javascript"></script>

    - or are you saying that when the page loads you don't know which .js file you'll need?
     
    ezpz, Oct 31, 2007 IP
  3. teraeon

    teraeon Peon

    Messages:
    40
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hm... I've never tried this. I would just do a simple hello world function that you know works and try it.

    But make sure you try it in all the browsers. There were changes since IE 6 SP1 that disabled a lot of the remote scripting capabilites for security reasons.
     
    teraeon, Nov 1, 2007 IP
  4. travisbishop

    travisbishop Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'm saying that I want to call a remote .js file when I click on a link or button.
     
    travisbishop, Nov 1, 2007 IP
  5. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #5
    travisbishop, your question still doesn't make sense. a javascript file cannot be "called".

    do you want to include a javascript file dynamically?
    or do you want to call a function defined in a javascript file in a remote server?

    if it's the latter, it's not possible. the browser needs to download the script before it can do anything with it.
     
    phper, Nov 1, 2007 IP
  6. travisbishop

    travisbishop Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    It's the latter. Thanks anyway for the help. Now I know what I need to do.
     
    travisbishop, Nov 1, 2007 IP