...

View Full Version : Javascript/ Internet Explorer 9 issues



chasero13
11-06-2012, 09:19 PM
I have the following script on a website:

<script language="javascript">
function toggle(targetId) {
target = document.all(targetId);
if (target.style.display == "none"){
target.style.display="";
} else {
target.style.display="none";
}
}
//-->
</script>

<font color="red" size="4" face="helvetica"><a href="javascript:toggle('Link1')"><font color="red">EXAMPLE</font></a>
<div id="Link1" style="display: none"></font>

<div align="left"><font color="#4a4a4a" size="2" face="helvetica">Example only. Example only. Example only.</font></div>
</div>

Code works fine on Internet explorer 6, chrome and opera. However, on internet explorer 9, it does not work. I have verified browser settings. Any help is appreciated. Thanks

felgall
11-06-2012, 10:02 PM
document.all is for IE4 - for IE5 and later as well as all other modern browsers use document.getElementById

Logic Ali
11-06-2012, 10:47 PM
I have the following script on a website:

Then lose it along with javascript:, language="javascript" and <font>, all of which are unnecessary or deprecated.


<script type="text/javascript">

function toggle( targetId )
{
var elem = document.getElementById( targetId );

elem.style.display = ( elem.style.display == "none" ? "block" : "none" );

return false;
}

</script>

<a href="#" onclick="return toggle('Link1')">EXAMPLE</a>
<div id="Link1" style="display: none">
<div align="left"><font color="#4a4a4a" size="2" face="helvetica">Example only. Example only. Example only.
</div>
</div>

Philip M
11-07-2012, 09:11 AM
As I quite frequently say,

The <!-- and //--> comment (hiding) tags have not been necessary since IE3 (i.e. since September 1997). If you see these in some published script it is a warning that (as in this case) you are looking at ancient and perhaps unreliable code.

Surely Chrome and Opera do not recognise document.all? That is IE specific.

rnd me
11-08-2012, 12:55 AM
IE9 shouldn't recognize document.all() if the page validates...

Old Pedant
11-08-2012, 01:24 AM
IE9 can *either* be standards compliant or older-IE-compliant.

The best thing to do is simply forget that document.all *EVER* existed.

It ceased to be needed when MSIE 5.0 arrived...in MARCH 1999.

So are you REALLY going to worry about MSIE 4? A program made obsolete over THIRTEEN YEARS AGO???

Sheesh.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum