Results 1 to 4 of 4

Thread: Javascript links die

  1. #1
    Join Date
    Nov 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Javascript links die

    Hey all,

    I have a webpage that has two javascript hyperlinks like the one below:

    <a href="javascript:ModGame('noob')" title='Your a newb!'>
    <img src="noob.gif">

    They feed through this link:

    <script src="http://www.hahanoobies.com/noobtoob.jhtm"></script>


    They are within a <div> element. When i save the webpage to my desktop,the links work perfectly and launch correctly. Although I have to click the "allow active content" message at the top of internet explorer.

    The problem i have is that when i upload them to my website host and load the page from their Unix the links dont work atall. I roll over the noob.gif and the command appears at the bottom of the page but when i click nothing happens.

    I can not understand why it works on my desktop but not on the server.

    Please help me as im a no0b,

    regards,

    UB xD

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    "Feed through a link?"

    In any case, don't use javascript: links. Links should only be used if there's an acceptable alternative URL.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Nov 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi, what i meant was the Javascript commands run from the commands on the .jhtm file. What is the alternative way of writing the hyperlink?

    Thanks

    UB xD

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by ubernoobz
    <a href="javascript:ModGame('noob')" title='Your a newb!'>
    <img src="noob.gif">
    Even allowing the

    href="javascript: . . ."

    convention which has numerous drawbacks but does usually work, you haven't closed your anchor tag. This can cause real problems at times. Unless you want to provide alternate content for non-javascript enabled browsers, you don't even need an anchor tag:

    HTML Code:
    <span style="cursor:pointer;" onclick="ModGame('noob');" title="Your a newb!"><img src="noob.gif"></span>
    This bit needs a type attribute:

    Code:
    <script type="text/javascript" src="http://www.hahanoobies.com/noobtoob.jhtm"></script>
    and:

    Code:
    http://www.hahanoobies.com/noobtoob.jhtm
    must work out to be a valid javascript with all paths to its external resources (if any) absolute or relative to the page that is using it - and be available on (via the script tag) and to the page that is using it.

    .jhtm isn't an extension I recognize. If it isn't required for server-side execution, best to use .txt or, better yet, .js and rename the source file accordingly. If it isn't on your domain and you don't have permission to use it, domain checking may be preventing it from functioning except on its home site or on a local implementation.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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