Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q911 Are there any instances where the use of javascript: in a href attribute causes problems?

irt.org | Knowledge Base | JavaScript | Link | Q911 [ previous next ]

Q911 Are there any instances where the use of javascript: in a href attribute causes problems?

This is okay:

<a href="javascript:myFunctionName()"><img="...></A>

However, the following can cause problems:

<a href="javascript:history.back()"><img="...></a>

It can cause a blank page to be loaded with the text: javascript:history.back() displayed.

Change it to something like:

<script language="JavaScript"><!--
function myFunctionName() {
    history.back();
}
//--></script>

<a href="javascript:myFunctionName()"><IMG="...></a>

Better yet make them browser friendly:

<script language="JavaScript"><!--
function myFunctionName() {
    history.back();
}
//--></script>

<a href="default.htm" onClick="this.href='javascript:myFunctionName()'"><img="...></a>

Feedback on 'Q911 Are there any instances where the use of javascript: in a href attribute causes problems?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.