Forum Moderators: open
<script language="Javascript">
function WriteLayer(ID,parentID,sText) {
if (document.layers) {
var oLayer;
if(parentID){
oLayer = eval('document.' + parentID + '.document.' + ID + '.document');
}else{
oLayer = document.layers[ID].document;
}
oLayer.open();
oLayer.write(sText);
oLayer.close();
}
else if (parseInt(navigator.appVersion)>=5&&navigator.
appName=="Netscape") {
document.getElementById(ID).innerHTML = sText;
}
else if (document.all) document.all[ID].innerHTML = sText
}
</script>
<form>
<br><br>
<input type="button" value="Display Time" onclick="WriteLayer
('MyLayer',null,Date())">
</form>
That is the script i've started with. It's copied from an article, but the article doesn't go in depth as to how to make a layer display anything other than the date! My JavaScript knowledge is limited, and i imagine it involves coding functions that write the text you want displayed and then calling on them where the Date() function is displayed, but i'm toying with it in Notepad and can't quite get it right... any help with this would be appreciated immensely... thanks```
i dont see an area for strictly javascript related discussion... i see it in the html area though so i thought it would be the best place for it. i was suprised by that.
"More than one time" -- click the button again...am I missing something?
If you explain what you are trying to do then I'm sure there are several people around who can give you a hand getting it working.
Jordan
Anyway, i want to change
<form>
<br><br>
<input type="button" value="Display Time" onclick="WriteLayer
('MyLayer',null,Date())">
</form>
to something like
<form>
<br><br>
<input type="button" value="Display Time" onclick="WriteLayer
('MyLayer',null,document.write('words here'))">
</form>
...so Yeah, Text. I just can't see any reason why this wouldn't work. where in the code does sText keep me from doing this? it boggles my mind. If anybody has some insight, i will tell you where a leprechan lives and he will give you some gold.
Edit: I misread, sorry. :)
If you just want to write text you can do:
<form>
<br><br>
<input type="button" value="Display Time" onclick="WriteLayer
('MyLayer',null,'Blah blah blah')">
</form>
Jordan
[edited by: MonkeeSage at 5:48 am (utc) on Sep. 1, 2003]
Try this:
<form>
<br><br>
<input type="button" value="Display Text" onclick="WriteLayer('MyLayer',null,'text here')">
</form>
<added>
You're faster than I am tonight, Jordan
</added>
Haha, and about that misreading -- i read through my post 4 times trying to find where i said that to see what you meant, and completely forgot what i titled the post. It's my fault for not using the article 'the' . . . i just usually read these titles and they sound like newspaper headlines. I am so happy this works now, thank you, both of you.