We help IT Professionals succeed at work.

JavaScript Error MSIE8 Object does not support this property or method

rhandalthor
rhandalthor used Ask the Experts™
on
When I open a site in IE* I get a Done, but with errors warning. When I open the warning I get
Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
Timestamp: Tue, 6 Jul 2010 07:52:25 UTC


Message: Object doesn't support this property or method
Line: 318
Char: 1
Code: 0
URI: http://domain.com/templates/ja_ruby/js/ja.script.js

In that JavaScript on line 318 there is:
window.addEvent ('load', function() {
      equalHeight();
      //new MenuIcon($E('#ja-mainnav'));
});

What is the issue here? Not really proficient in JavaScript so no clue yet.

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Shinesh PremrajanEngineering Manager
Commented:
window.addEventListener("load",equalHeight,false);

hope this helps

Author

Commented:
Made the changes:
window.addEventListener("load",equalHeight,false);
//window.addEvent ('load', function() {
//      equalHeight();
      //new MenuIcon($E('#ja-mainnav'));
//});

and got new error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
Timestamp: Tue, 6 Jul 2010 08:32:19 UTC


Message: Object doesn't support this property or method
Line: 317
Char: 1
Code: 0
URI: http://domain.com/templates/ja_ruby/js/ja.script.js

which is referring to the new line of code you posted. Do I need to add curly braces?

Shinesh PremrajanEngineering Manager

Commented:
Could you paste the ja.script.js file here,  we need to look into it.

Author

Commented:
Here is a link to the actual site http://imagewize.net where you can check the JavaScript with Firebug. I think  there is a conflict between this script and the recently added All Video Joomla! http://extensions.joomla.org/extensions/multimedia/video-players-a-gallery/812 . I do not know why. But I really need to keep both. On the blog page there are 3 javascript error warnings.
/*------------------------------------------------------------------------
# JA Ruby for Joomla 1.5 - Version 1.0 - Licence Owner JA43263
# ------------------------------------------------------------------------
# Copyright (C) 2004-2008 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
# @license - Copyrighted Commercial Software
# Author: J.O.O.M Solutions Co., Ltd
# Websites:  http://www.joomlart.com -  http://www.joomlancers.com
# This file may not be redistributed in whole or significant part.
-------------------------------------------------------------------------*/
function switchFontSize (ckname,val){
	var bd = $E('body');
	switch (val) {
		case 'inc':
		if (CurrentFontSize+1 < 7) {
			bd.removeClass('fs'+CurrentFontSize);
			CurrentFontSize++;
			bd.addClass('fs'+CurrentFontSize);
		}
		break;
		case 'dec':
		if (CurrentFontSize-1 > 0) {
			bd.removeClass('fs'+CurrentFontSize);
			CurrentFontSize--;
			bd.addClass('fs'+CurrentFontSize);
		}
		break;
		default:
		bd.removeClass('fs'+CurrentFontSize);
		CurrentFontSize = val;
		bd.addClass('fs'+CurrentFontSize);
	}
	Cookie.set(ckname, CurrentFontSize,{duration:365});
}

function switchTool (ckname, val) {
	createCookie(ckname, val, 365);
	window.location.reload();
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };

//addEvent - attach a function to an event
function jaAddEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}

function equalHeight(){	
	//var box;
	if ($('ja-botsl1')) {
		var box = $$(getElementsByClass ('ja-boxct-wrap', $('ja-botsl1'), "div"));
		if (box && box.length>1) {
		   makeEqualHeight(box);
	  }
	}
}

function makeEqualHeight(divs, offset) {
	if (!offset) offset = 0;
	if(!divs || divs.length < 2) return;
	var maxh = 0;
	divs.each(function(el, i){
		var ch = el.getCoordinates().height;
		maxh = (maxh < ch) ? ch : maxh;
	},this);
	maxh += offset;
	divs.each(function(el, i){
		el.setStyle('height', maxh-el.getStyle('padding-top').toInt()-el.getStyle('padding-bottom').toInt());
	},this);
}

function getDeepestDiv (div) {
	while (div.getChildren().length==1 && (div.getChildren()[0].tagName == 'DIV'))
	{
		div = div.getChildren()[0];
	}
	return div;
}

function preloadImages () {
	var imgs = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var imgsrc = arguments[i];
		imgs[i] = new Image();
		imgs[i].src = imgsrc;
	}
}

//Add span to module title
function addSpanToTitle () {
	//var colobj = document.getElementById ('ja-col');
	//if (!colobj) return;
	var modules = getElementsByClass ('module.*', null, "div");
	if (!modules) return;
	for (var i=0; i<modules.length; i++) {
		var module = modules[i];
		var title = module.getElementsByTagName ("h3")[0];
		if (title) {
			text = title.innerHTML;
			title.innerHTML = "<span>"+text+"</span>";
		}
	}
}

function addSpanToTitle3 () {
	//var colobj = document.getElementById ('ja-col');
	//if (!colobj) return;
	var modules = getElementsByClass ('moduletable.*', null, "div");
	if (!modules) return;
	for (var i=0; i<modules.length; i++) {
		var module = modules[i];
		var title = module.getElementsByTagName ("h3")[0];
		if (title) {
			text = title.innerHTML;
			title.innerHTML = "<span>"+text+"</span>";
		}
	}
}

function addSpanToTitle2 () {
	//var colobj = document.getElementById ('ja-col');
	//if (!colobj) return;
	var modules = $$(getElementsByClass ('module.*', null, "div"));
	var mod_products = null;
	if ($('ja-productwrap')) mod_products = $$(getElementsByClass ('module.*', $('ja-productwrap'), "div")); //$('ja-productwrap').getElements ('div.moduletable');
	if (!modules) return;
	modules.each (function (mod){
		var title = mod.getElement ('h3');
		if (!title) return;
		var text = title.getText();
		if (mod_products && mod_products.contains(mod)) {
			var texts = text.split (' ');
			texts[texts.length-1] = '<span>'+texts[texts.length-1]+'</span>';
			title.setHTML (texts.join(' '));
		} else {
			title.setHTML ('<span>'+text+'</span>');
		}
	});
}

function makeTransBg(el, bgimgdf, sizingMethod, type, offset){
	var objs = el;
	if(!objs) return;
	if ($type(objs) != 'array') objs = [objs];
	if(!sizingMethod) sizingMethod = 'crop';
	if(!offset) offset = 0;
	var blankimg = siteurl + 'images/blank.png';
	objs.each(function(obj) {
		var bgimg = bgimgdf;
		if (obj.tagName == 'IMG') {
			//This is an image
			if (!bgimg) bgimg = obj.src;
			if (!(/\.png$/i).test(bgimg) || (/blank\.png$/i).test(bgimg)) return;

			obj.setStyle('height',obj.offsetHeight);
			obj.setStyle('width',obj.offsetWidth);
			obj.src = blankimg;
			obj.setStyle ('visibility', 'visible');
			obj.setStyle('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+bgimg+", sizingMethod='"+sizingMethod+"')");
		}else{
			//Background
			if (!bgimg) bgimg = obj.getStyle('backgroundImage');
			var pattern = new RegExp('url\s*[\(\"\']*([^\'\"\)]*)[\'\"\)]*');
			if ((m = pattern.exec(bgimg))) bgimg = m[1];
			if (!(/\.png$/i).test(bgimg) || (/blank\.png$/i).test(bgimg)) return;
			if (!type)
			{
				obj.setStyles({'background': 'none'});

				if(obj.getStyle('position')!='absolute' && obj.getStyle('position')!='relative') {
					obj.setStyle('position', 'relative');
				}

				obj.getChildren().each(function(el){
					if(el.getStyle('position')!='absolute' && el.getStyle('position')!='relative')
					{
						el.setStyle('position', 'relative');
					}
					el.setStyle('z-index',2);
				});
				//Create background layer:
				var bgdiv = new Element('IMG');
				bgdiv.src = blankimg;
				bgdiv.width = obj.offsetWidth - offset;
				bgdiv.height = obj.offsetHeight - offset;
				bgdiv.setStyles({
				'position': 'absolute',
				'top': 0,
				'left': -obj.getStyle('padding-left').toInt()
				});

				bgdiv.className = 'TransBG';

				bgdiv.setStyle('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+bgimg+", sizingMethod='"+sizingMethod+"')");
				bgdiv.inject(obj, 'top');
				//alert(obj.innerHTML + '\n' + bgdiv.innerHTML);
			} else {
				obj.setStyle('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+bgimg+", sizingMethod='"+sizingMethod+"')");
			}
		}
	}.bind(this));
}

function isIE6() {
	version=0
	if (navigator.appVersion.indexOf("MSIE")!=-1){
		temp=navigator.appVersion.split("MSIE")
		version=parseFloat(temp[1])
	}
	return (version && (version < 7));
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	var j = 0;
	if ( node == null )
	node = document;
	if ( tag == null )
	tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (var i = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	//alert(searchClass + j);
	return classElements;
}

//Add 1st item identity
jaAddFirstItemToTopmenu = function() {
	li = $E('#ja-topnav ul li');
	if(li) {
		li.addClass('ja-firstitem');
	}
}

jaRemoveLastContentSeparator = function () {
	var els = $$('#ja-content .article_separator');
	if (els && els.length) els[els.length-1].remove();
}

jaRemoveLastTrBg = function () {
	var els = $$('#ja-topsl3 tr');	
	if (!els || els.length<1) return;
	var obj = els[els.length-1];
	if (els[els.length-1].innerHTML.trim()=='' && els.length>2) {
		obj.remove();
		obj = els[els.length-2];
	}
	if (obj) obj.setStyle('background','none');
}

fixMenuWidth = function() {
	//Fix for dropline and split menu
	if (!$('ja-splitmenu')) return;
	var lis = $('ja-splitmenu').getElement('ul').getChildren();
	if (lis.length)
	{
		var w = Math.floor($('ja-mainnav').offsetWidth / lis.length);
		lis.setStyle ('width', w);
	}
}

moveReadmore = function () {
	var articles = $$('.contentpaneopen');
	if (!articles) return;
	articles.each(function(article) {
		var readmore = article.getElement('.readon');
		var article_content = article.getElement('.article-content');
		if (readmore && article_content) {
			readmore.remove().inject(article_content);
		}
	});
}

addIEHover = function() {
	if (!window.ie6) return;
	var obj = $('ja-topsl');
	if (!obj || !obj.getChildren()) return;
	obj.getChildren().each(function(el){
		var cls = 'topsl-hover-center';
		if (el.className.test ('ja-box-left')) {
			cls = 'topsl-hover-left';
		}
		if (el.className.test ('ja-box-right')) {
			cls = 'topsl-hover-right';
		}
		el.addEvent('mouseenter', function(){
			el.addClass(cls);
		}.bind(this));
		el.addEvent('mouseleave', function(){
			el.removeClass(cls);
		}.bind(this));
	});
}

window.addEvent ('load', function() {
	equalHeight();
	//new MenuIcon($E('#ja-mainnav'));
});

//last fix removed

var boxes = [];
showBox = function (box,focusobj, caller) {
	box=$(box);
	if (!box) return;
	if ($(caller)) box._caller = $(caller);
	boxes.include (box);
	if (box.getStyle('display') == 'none') {
		box.setStyles({
			display: 'block',
			opacity: 0
		});
	}
	if (box.status == 'show') {
		//hide
		box.status = 'hide';
		var fx = new Fx.Style (box,'opacity');
		fx.stop();
		fx.start (box.getStyle('opacity'), 0);
		if (box._caller) box._caller.removeClass ('show');
	} else {
		boxes.each(function(box1){
			if (box1!=box && box1.status=='show') {
				box1.status = 'hide';
				var fx = new Fx.Style (box1,'opacity');
				fx.stop();
				fx.start (box1.getStyle('opacity'), 0);
				if (box1._caller) box1._caller.removeClass ('show');
			}
		},this);
		box.status = 'show';
		var fx = new Fx.Style (box,'opacity',{onComplete:function(){if($(focusobj))$(focusobj).focus();}});
		fx.stop();
		fx.start (box.getStyle('opacity'), 1);
		
		if (box._caller) box._caller.addClass ('show');
	}
}

//Add event for slideshow
slideshowOnWalk = function () {
	if (window.JaSlideshow) {
		var n = JaSlideshow.options.images.length;
		var inactive_opacity = 0.4;
		for (var i=0; i<n; i++) {
			var thumb = $('jsnav'+i);
			if (!thumb || thumb.className.test('active')) continue;
			thumb.setStyle ('opacity', inactive_opacity);
		}
		//add mask
		JaSlideshow.mask = new Element ('div', {'id':'ja-slideshow-mask'}).inject (JaSlideshow.elementdiv);
    if (JaSlideshow.options.urls) {
      JaSlideshow.mask.setStyle ('cursor', 'pointer');
  		JaSlideshow.mask.onclick = function() {
  			location.href = JaSlideshow.options.urls[0];
  		}
  	}
		JaSlideshow.onWalk = function (current) {
			//alert (current);
			var fxOptions = {duration:JaSlideshow.options.duration[0], wait:false}
			var thumb1 = $('jsnav'+current[2]);
			thumb1fx = new Fx.Style (thumb1, 'opacity', fxOptions);
			thumb1fx.start (inactive_opacity);
			var thumb2 = $('jsnav'+current[0]);
			thumb2fx = new Fx.Style (thumb2, 'opacity', fxOptions);
			thumb2fx.start (1);
			//thumb.setStyle ('opacity', 0.7);
      if (JaSlideshow.options.urls) {
  			JaSlideshow.mask.onclick = function() {
  				location.href = JaSlideshow.options.urls[current[2]];
  			}
  		}
		}
	}
}

jaMenuIcon = function () {
	var icons = $$('#ja-splitmenu img');
	var actives = $$('#ja-splitmenu li.active img');
	if (!icons) return;
	icons.each (function(img){
		var src = img.src;
		//get path for active image
		if (!(pos = src.lastIndexOf ('.'))) return;
		img.ext = src.substr(pos);
		img.src_on = src.substr (0, pos) + '-on' + src.substr(pos);
		img.src_off = src;
		if (img.ext=='.png' && window.ie6) {
			img.src_on = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+img.src_on+'\', sizingMethod=\'image\')';
			img.src_off = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+img.src+'\', sizingMethod=\'image\')';
			img.src = siteurl + 'images/blank.png';
			img.setStyle ('filter', img.src_off);
		}
		//preload image
		var image = new Image ();
		image.src = img.src_on;
		//if (!image.width || !image.height) return; //Image not found
		//Switch image for active item
		if (actives && actives.contains (img)) {
			if (img.ext=='.png' && window.ie6) {
				img.setStyle ('filter', img.src_on);
			} else {
				img.src = img.src_on;
			}	
			return;
		}
		//Set event
		img.getParent().addEvent ('mouseenter', function () {
			if (img.ext=='.png' && window.ie6) {
				img.setStyle ('filter', img.src_on);
			} else {
				img.src = img.src_on;
			}
		},this);
		
		img.getParent().addEvent ('mouseleave', function () {
			if (img.ext=='.png' && window.ie6) {
				img.setStyle ('filter', img.src_off);
			} else {
				img.src = img.src_off;
			}	
		},this);
	});
}

ja_topsl_button = function () {
	var button = $('ja-topsl-button');
	if (button) {
		button.el = $('ja-topslwrap');
		button.el.setStyles({'position':'relative','overflow': 'hidden'});
		button.fx = new Fx.Style (button.el, 'height');
		button._maxh = button.el.offsetHeight;
		button._status = true;
		button._alt = button.title;
		button.title = button.getText();
		button.addEvent ('click', function() {
			var h = this._status?0:(this.el.scrollHeight-20);
			this.fx.start (h);
			this._status = !this._status;
			this.setText (this._alt);
			this._alt = this.title;
			this.title = this.getText();
			return false;
		});
	}
}

Open in new window

Author

Commented:
Reading this: http://forum.joomlaworks.gr/allvideos-%28plugin%29/errors-with-allvideos-code/ and Googling. Wonder if AllVideo uses JavaScript and if it cannot handle my CSSJSCompress plugin

Author

Commented:
Firefox/Frebug mentions window.addEvent is not a function twice referring to  AllVideo script and ja.script.js which is the earlier attached js script that is part of the template. IE8 mentions 3 errors.

Author

Commented:
Upgraded to CssJsCompress 3.5, but still a object doesn't support property or method in ja.script.js on line 318 (original function) And on the blog page still three errors. I do not fully comprehend what is the problem anways..
Engineering Manager
Commented:
Referring the Js file it seems its not the problem with the window.event function but the included function in it.

just try disabling that function in the js.script.js file.

like

window.addEvent('load', function() {
alert('window.addEvent Loaded');
      //equalHeight();      
});

Since the code seems to complex, any way, do you remember when it stop functioning, after adding any particular code or something. Just check the equalHeight or the functions that are called within it.


Hope this helps
Commented:
Hi - well the javascript is in the template - so firstly to confirm this change templates  in templaet manager  - and I expect  the error will vanish - in theory - if this is  purchased template - you should go back to the developers and ask them to fix it.

In my experieice this is often related to the units in say this case for the height measurement... eg px etc

You can't disable this because it makes your templates columns even -

It MAY be conflicting with another addon as shunug suggests - turn ALL adons off and see if that helps

Author

Commented:
@ Shinuq I unfortunately do not remember when these errors popped up. I use Firefox more often than Internet Explorer.. But it could be related to an Joomla! upgrade a while ago, the CSSJSCompress plugin or the very recently added AllVideo plugin as I mentioned earlier. I now added:
window.addEvent('load', function() {
alert('window.addEvent Loaded');
      //equalHeight();      
});

to ja.script.js, but the error is still shown in IE8.
I unpublished the  mod_jTweet  which removed one JavaScript warning. I was not loading Tweets properly anyways. Now only the error on line 318 of ja.script.js remains it seems

Author

Commented:
@ j-b-t: when I turn off CSSJsCompress plugin all errors are gone. I would prefer to keep it running though so I will see if I can exclude ja.script.js and keep the plugin running. Somehow the compression of JavaScript messes thinsg up for IE.

Author

Commented:
Will continue questions here: http://www.joomlatags.org/forum/view-topiclist/forum-1-cssjscompress.html and close this thread. Thanks everyone!