Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | Link | Q911 [ previous next ]

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?'

©2018 Martin Webb