...

View Full Version : not implemented error, window.onload problem



johnny_n
12-20-2007, 03:57 PM
Hello all

I have used a function from Jeremy Keith's book, "dom scripting" , the function is used to add extra functions to the window.onload event.

the problem is I get a "error : not implemented" error in IE, no errors in firefox.

I believe it must be the way I am using this function because the function actually executes properly, and I have seen it working on other peoples sites ok.
I believe it is quite common now. here is the code


function addLoadEvent(func){
var oldonload = window.onload;
if(typeof window.onload != 'function'){
window.onload = func;
} else {
window.onload = function() {

oldonload();
func();
}
}
}


here is the entire page



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml-transitional.dtd">
<html xmlns="http://www.w3c.org/1999/xhtml">
<head>
<meta http-equiv="Content Type" content="text/html; charset=utf-8" />
<title> javascript test page</title>
<script type="text/javascript">
function addLoadEvent(func){
var oldonload = window.onload;
if(typeof window.onload != 'function'){
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
//oldonload();
//func();
}
}
}

function removeChildrenFromNode(node)
{
if(node !== undefined &&
node !== null)
{
return;
}

var len = node.childNodes.length;

while (node.hasChildNodes())
{
node.removeChild(node.firstChild);
}
}


function makeImageGroups(color_name,product_code) {
var imageGroup = new Array();

var countone=0;
for (var i=0; i < imageArray.length; i++){

if (imageArray[i][0].substr(0,3) == color_name){
imageGroup[countone] = new Array();
imageGroup[countone][0] = imageArray[i][0];
imageGroup[countone][1] = imageArray[i][1];
imageGroup[countone][2] = imageArray[i][2];
countone++;


}

}
for (var i=0; i < imageGroup.length ; i++) {
alert("l= " + imageGroup.length + " - " +imageGroup[i][0] +" - " + imageGroup[i][1]+" - "+imageGroup[i][2]);
}

var myGallery = document.getElementById("LightBoxGallery");
if(myGallery.hasChildNodes) removeChildrenFromNode(myGallery);

myGalleryTitle = document.createElement("div");
myGalleryTitleText = document.createTextNode("Image Gallery - " + (imageGroup.length) + " extra images");
myGalleryTitle.setAttribute("id","LightBoxGalleryTitle");
myGalleryTitle.appendChild(myGalleryTitleText);
myGallery.appendChild(myGalleryTitle);


for (var i=0; i < imageGroup.length ; i++) {

galleryPicDiv = document.createElement("div");
galleryPicDiv.setAttribute("class","LightBox");
galleryPicLink = document.createElement("a");
galleryPicLink.setAttribute("href","/images/uploads/"+product_code+"/"+imageGroup[i][0]);
galleryPicLink.setAttribute("title","use arrows to scroll");
galleryPicLink.setAttribute("rel","lightbox[imageset]");
galleryPicImg = document.createElement("img");
galleryPicImg.setAttribute("src","/images/uploads/"+product_code+"/thumbs/"+imageGroup[i][0]);
galleryPicImg.setAttribute("width",75*(imageGroup[i][1]/imageGroup[i][2]));
galleryPicImg.setAttribute("height",75);
galleryPicImg.setAttribute("border",0);
galleryPicImg.setAttribute("alt","/");
galleryPicImg.setAttribute("class","LightBoxImage");

galleryPicLink.appendChild(galleryPicImg);
galleryPicDiv.appendChild(galleryPicLink);
myGallery.appendChild(galleryPicDiv);


}
}

</script>
</head>
<body>
<div id="LightBoxGallery">
</div>

<script type="text/javascript">
var imageArray = new Array();

imageArray[0] = new Array();
imageArray[0][0] = "BLK2.jpg"; imageArray[0][1] = "341";imageArray[0][2] = "520";

imageArray[1] = new Array();
imageArray[1][0] = "BLK3.jpg"; imageArray[1][1] = "951";imageArray[1][2] = "525";

imageArray[2] = new Array();
imageArray[2][0] = "BLK4.jpg"; imageArray[2][1] = "525";imageArray[2][2] = "520";

imageArray[3] = new Array();
imageArray[3][0] = "BLK5.jpg"; imageArray[3][1] = "856";imageArray[3][2] = "525";

imageArray[4] = new Array();
imageArray[4][0] = "BLK6.jpg"; imageArray[4][1] = "699";imageArray[4][2] = "525";

imageArray[5] = new Array();
imageArray[5][0] = "BLK7.jpg"; imageArray[5][1] = "710";imageArray[5][2] = "525";

imageArray[6] = new Array();
imageArray[6][0] = "BRZ2.jpg"; imageArray[6][1] = "336";imageArray[6][2] = "520";

imageArray[7] = new Array();
imageArray[7][0] = "BRZ3.jpg"; imageArray[7][1] = "891";imageArray[7][2] = "514";

imageArray[8] = new Array();
imageArray[8][0] = "BLK8.jpg"; imageArray[8][1] = "410";imageArray[8][2] = "520";

addLoadEvent(makeImageGroups("BRZ","BRVL"));
</script>
</body>
</html>


thanks

Arty Effem
12-20-2007, 04:05 PM
Hello all

I have used a function from Jeremy Keith's book, "dom scripting" , the function is used to add extra functions to the window.onload event.

the problem is I get a "error : not implemented" error in IE, no errors in firefox.



addLoadEvent(makeImageGroups("BRZ","BRVL"));



Try addLoadEvent(function(){makeImageGroups("BRZ","BRVL")});

johnny_n
12-20-2007, 04:39 PM
thanks Arty,

it worked with your corrections, I love dom.:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum