PDA

View Full Version : Help with Javascript and combining iframes and Netscape layers features?



OO7girl
06-08-2004, 07:52 PM
Hello all,

I have a script that displays a certain .txt file in an iframe depending on the day of the year, which I have included below. The problem is that I need the page to work in both IE and Netscape 4.79 and higher. Because Netscape 4.79 does not support iframes, I need to figure out a way to display the .txt files properly if the site visitor uses Netscape. I have tried nesting <div> or <layer> tags with the <iframe> tags, but nothing seems to work. I am a relative Javascript newbie. :(

If anyone has any suggestions, I would be greatly indebted!

Here is the script:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
var now=new Date();
function getTxt(){
nowM=now.getMonth()+1;
nowD=now.getDate();
nowM=(nowM<10)?'0'+nowM:nowM;
nowD=(nowD<10)?'0'+nowD:nowD;
document.getElementById('todayInH').src=nowM+nowD+'fra.txt';//for French
}
//-->
</script>
</head>
<body onload="getTxt()">
<iframe scr="" id="todayInH"></iframe>
</body>
</html>

jbot
06-09-2004, 10:48 AM
only NN4.x supports ilayers or layers, whereas NN6+ and Moz support iframes too, tho iframes are deprecated under XHTML strict.

this bit of code might help:


<script>
<!--
document.layers ? document.writeln('<ilayer id="todayInH" src=""></ilayer>') : document.writeln('<iframe scr="" id="todayInH"></iframe>') ;

// -->
</script>

sidvorak
06-09-2004, 08:04 PM
007Girl,

You will also have a problem using document.getElementById in netscape 4.79 as
it does not support DOM functions.

Why are you stuck with supporting Netscape 4?

Cheers,
Simon