RobG said:
white said:
I have the following function:
function overwrite(div_id, image_id) {
if (document.getElementById(div_id).style.display=="none") {
document.getElementById("spex").innerHTML = "<a
href="+"javascript

verwrite('sp', 'img1')"+">Close</a>";
[...] You should not abuse a link this way: a link is expected
to open a new page or navigate to some other location, it is not
expected to be script-dependent. You should be using a button:
document.getElementById("spex").innerHTML =
'<button onclick="overwrite(\'sp\', \'img1\');">Close</button>';
For a button that has only a text as caption, the `input' element with the
`type' attribute value `button' should be used instead of the `button'
element because it is much more compatible.
The return value of methods should not be used as a reference base without a
prior type-converting test. A TypeError exception will be thrown (or the
equivalent of that happens of ES3 is not implemented) if the returned value
is not of type Reference, and the entire script may break at this point.
The proprietary `innerHTML' property should be avoided, and standardized
creator and mutator methods of W3C DOM Level 2 Core (or, where not
available, their proprietary equivalents) should be used instead. If
`innerHTML' is used anyway, it should not be used without a prior feature
test, especially not when in conjunction with DOM Level 2 methods:
var spex = document.getElementById("spex");
if (spex && typeof spex.innerHTML != "undefined")
{
spex.innerHTML = '<input type="button" value="Close"'
+ ' onclick="overwrite(\'sp\', \'img1\');">';
}
PointedEars