PDA

View Full Version : Is this right?



Tabo
08-01-2007, 09:34 PM
Solved:

<script ...>
function Something(ID){
if(document.getElementById){
var GetResultId = document.getElementById(ID);
}
else if (document.all){
var GetResultId = document.all[ID];
}
else if (document.layers){
var GetResultId = document.layers[ID];
}
else{
return false;
}
GetResultId.innerHTML = "Whatever";

}


</script>



Also is it:

function Something(form){
document.forms[form].whatever...

}

jscheuer1
08-02-2007, 01:37 AM
The document.layers part won't work, but that is rarely used. Not since NN4, I believe. The rest will work.

See:

http://www.quirksmode.org/js/layerwrite.html

Added Later:

This seems to also work out fairly well:


<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">
function Something(ID) {
var text='whatever', d=document.layers||document.all||null;
var x=d? d[ID] : document.getElementById? document.getElementById(ID) : null;
if (document.getElementById)
x.innerHTML = '';
if (document.layers){
x.document.open();
x.document.write(text);
x.document.close();
}
else if(x)
x.innerHTML = text;
return false;
}
</script>
</head>
<body>
<div>
<div id="blah"><layer name="blah"></layer><br></div>

<a href="#" onclick="return Something('blah');">test</a>
</div>
</body>
</html>

Tabo
08-02-2007, 05:14 PM
Ok and how about this:

function Something(form){
document.forms[form].whatever...

}

jscheuer1
08-02-2007, 09:02 PM
Ok and how about this:

function Something(form){
document.forms[form].whatever...

}

What about it?