View Full Version : Javascript links die

11-03-2006, 06:31 PM
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,



11-03-2006, 06:40 PM
"Feed through a link?"

In any case, don't use javascript: links. Links should only be used if there's an acceptable alternative URL.

11-03-2006, 06:59 PM
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?



11-03-2006, 07:17 PM
<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:

<span style="cursor:pointer;" onclick="ModGame('noob');" title="Your a newb!"><img src="noob.gif"></span>

This bit needs a type attribute:

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



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.