...

View Full Version : IE weird javascript console ...



_com
07-09-2005, 03:58 PM
In IE 6 WIN I got a js console error message saying that an object is expected when writng the script like this:



<script type="text/javascript">
document.getElementById('largeImage').onload=function(){
unhideAllDivs ();
}
</script>

In IE 6 WIN doing this no js errors any more


<script type="text/javascript">
var document.getElementById('largeImage') = 'largeImg' ;
largeImg.onload=function(){
unhideAllDivs ();
}
</script>

What caused the error in the version without the declared var in IE 6 WIN ?
Is there a better way to write this?

vwphillips
07-09-2005, 06:17 PM
answered wrong post

vwphillips
07-09-2005, 06:31 PM
best try and say somthing after above

but I have no idea what


var document.getElementById('largeImage') = 'largeIm' ;

is trying to achieve

but if you are trying to load a large image

this will change the image if it is found
but probably before its loaded




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<title></title>
<script language="JavaScript" type="text/javascript">
<!--

function PreLoad(){
largeIm=new Image();
largeIm.onload=function(){ document.getElementById('largeImage').src=largeImg.src; unhideSmalDivs (); }
largeIm.src='MyImage.jpg';
}
</script>
</head>

<body>

</body>

</html>

_com
07-09-2005, 07:00 PM
No, this code snippet is to execute the script unhideAllDivs AFTER the image with id=largeImage has loaded.

My question was if it makes any difference if I would declare a variable

var largeImg = document.getElementbyId('largeImage');.

The javascript console that popped up in IE6 WIN XP gave an error saying object wass missing so that is why I put in an extra line to declare the var.

Will the var be set to null by itself after execution of the function?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum