Difference between revisions of "JavaScript links are evil"

From Nick Jenkins
Jump to: navigation, search
m
m (Good point, thank you, updating sentence more for IE7.)
 
(3 intermediate revisions by 2 users not shown)
Line 9: Line 9:
 
<a href="images/storyimages/040504_incident_report.html" target="_blank">report</a>
 
<a href="images/storyimages/040504_incident_report.html" target="_blank">report</a>
 
</pre>
 
</pre>
 +
 +
And this:
 +
<pre>
 +
<a href="javascript:KODAK('1.html')"  ...
 +
</pre>
 +
Would become this:
 +
<pre>
 +
<a href="1.html" target="_blank" ...
 +
</pre>
 +
 
This has the following advantages:
 
This has the following advantages:
 
# No loss of functionality - in fact, more functionality.
 
# No loss of functionality - in fact, more functionality.
Line 14: Line 24:
 
# Putting the cursor over the link shows in the status bar what it is - something that you don't get with JavaScript.
 
# Putting the cursor over the link shows in the status bar what it is - something that you don't get with JavaScript.
 
# Users hate popup windows.
 
# Users hate popup windows.
 +
# Works especially well in tabbed browsers (and now that IE7 has been released, every major browser is now a tabbed browser).
  
 
==Sites asked to consider above change==
 
==Sites asked to consider above change==
Line 19: Line 30:
 
! Site
 
! Site
 
! Date
 
! Date
! Result
 
 
|-
 
|-
 
| [http://spamgourmet.com SpamGourmet disposable email service].
 
| [http://spamgourmet.com SpamGourmet disposable email service].
 
| 15-Feb-2006
 
| 15-Feb-2006
| ''Response received''
+
|-
 +
| [http://www.photomichaelwolf.com/hongkongarchitecture/ Pictures of Hong Kong buildings].
 +
| 27-Feb-2006
 
|}
 
|}
  

Latest revision as of 01:34, 9 November 2006

Please don't use javascript for your links. Use standard HTML instead.

For example:

<a href="#" onClick="MM_openBrWindow('images/storyimages/040504_incident_report.html','','scrollbars=yes,width=840')">report</a>

There is simply no reason whatsoever for it. This works just as well like this:

<a href="images/storyimages/040504_incident_report.html" target="_blank">report</a>

And this:

<a href="javascript:KODAK('1.html')"  ...

Would become this:

<a href="1.html" target="_blank" ...

This has the following advantages:

  1. No loss of functionality - in fact, more functionality.
  2. Works even with Javascript turned off.
  3. Putting the cursor over the link shows in the status bar what it is - something that you don't get with JavaScript.
  4. Users hate popup windows.
  5. Works especially well in tabbed browsers (and now that IE7 has been released, every major browser is now a tabbed browser).

Sites asked to consider above change[edit]

Site Date
SpamGourmet disposable email service. 15-Feb-2006
Pictures of Hong Kong buildings. 27-Feb-2006