Javascript Error. window.addEvent is not a function?

General questions relating to Joomla! 1.5 There are other boards for more specific help on Joomla! features and extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Locked
User avatar
Siege21
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 132
Joined: Fri Feb 12, 2010 5:13 pm
Location: Ludlow, UK
Contact:

Javascript Error. window.addEvent is not a function?

Post by Siege21 » Wed Mar 09, 2011 5:05 pm

Hi there.

I've been working on a site for a client and this little error message has reared it's head and I can't seem to pinpoint it's cause;

Code: Select all

window.addEvent is not a function

window.addEvent('domready', function(){ setlayout(); }); 
That is pretty much all Firebug will tell me. So far the only thing it's causing problems for is a popup system message that I believe is built into the template. I didn't have any involvement with the template and inital setup, so I'm going in blind here. My Javascript is poor at best too, so any help with this would be greatly appreicated!

I've done a lot of digging and the only solutions to problems similar to this I found were to change "domready" to "load", but that only seemed relevant in IE, and besides, it did nothing when I tried it anyway.

Can anyone help me out?

Thank you in advance! :)
"Buy land! They've stopped making it" - Mark Twain

http://www.antonydoyle.co.uk

User avatar
jvezina
Joomla! Ace
Joomla! Ace
Posts: 1060
Joined: Thu Apr 13, 2006 4:25 am
Location: Denver, Colorado, USA
Contact:

Re: Javascript Error. window.addEvent is not a function?

Post by jvezina » Thu Mar 10, 2011 3:13 pm

You're calling window.AddEvent() before the mootools library is loaded.
Jim
website design, development, hosting and search engine optimization
http://www.IndustryWebHost.com

User avatar
Siege21
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 132
Joined: Fri Feb 12, 2010 5:13 pm
Location: Ludlow, UK
Contact:

Re: Javascript Error. window.addEvent is not a function?

Post by Siege21 » Thu Mar 10, 2011 3:53 pm

*self facepalm*

Thank you! It's all sorted now. :)
"Buy land! They've stopped making it" - Mark Twain

http://www.antonydoyle.co.uk

User avatar
jvezina
Joomla! Ace
Joomla! Ace
Posts: 1060
Joined: Thu Apr 13, 2006 4:25 am
Location: Denver, Colorado, USA
Contact:

Re: Javascript Error. window.addEvent is not a function?

Post by jvezina » Thu Mar 10, 2011 4:36 pm

hey, I know what you're going through. I was using mootools with another framework. The framework was nice enough to be inconsistent on when it'd load my files. So on most pages everything worked fine, but then there were the other pages when things got rearranged.
Jim
website design, development, hosting and search engine optimization
http://www.IndustryWebHost.com

User avatar
Siege21
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 132
Joined: Fri Feb 12, 2010 5:13 pm
Location: Ludlow, UK
Contact:

Re: Javascript Error. window.addEvent is not a function?

Post by Siege21 » Thu Mar 10, 2011 4:53 pm

It is frustrating. The developer used an obscure template framework which just seems to clash at every opportunity with the Joomla core. It's so bad I almost recommended I just re-build the whole site!!

Thanks again for your help.
"Buy land! They've stopped making it" - Mark Twain

http://www.antonydoyle.co.uk

sons
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Mar 14, 2011 8:40 am

Re: Javascript Error. window.addEvent is not a function?

Post by sons » Mon Mar 14, 2011 8:46 am

Hi,

I am newbie at this. Can somebody, please, explain me what to do to solve this problem?

Thanks in advance!

User avatar
jvezina
Joomla! Ace
Joomla! Ace
Posts: 1060
Joined: Thu Apr 13, 2006 4:25 am
Location: Denver, Colorado, USA
Contact:

Re: Javascript Error. window.addEvent is not a function?

Post by jvezina » Mon Mar 14, 2011 1:13 pm

Sorry to hear that. Sometimes it's hard to know when to stop throwing good money (& time) after bad.

And for sons, the mootools.js library needs to be loaded before the addEvent() function is called.
Jim
website design, development, hosting and search engine optimization
http://www.IndustryWebHost.com

sons
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Mar 14, 2011 8:40 am

Re: Javascript Error. window.addEvent is not a function?

Post by sons » Mon Mar 14, 2011 1:19 pm

Hi,
Where to set that? In what file or ...

Thanks

User avatar
jvezina
Joomla! Ace
Joomla! Ace
Posts: 1060
Joined: Thu Apr 13, 2006 4:25 am
Location: Denver, Colorado, USA
Contact:

Re: Javascript Error. window.addEvent is not a function?

Post by jvezina » Mon Mar 14, 2011 2:14 pm

The problem could actually be from anywhere, but the first place to check is the index.php file of your template.

Another good thing to do is look at the page source of your site to see what's calling the AddEvent function before mootools.js gets loaded (& joomla automatically includes mootools).
Jim
website design, development, hosting and search engine optimization
http://www.IndustryWebHost.com

Nibinaear
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Tue Jul 06, 2010 12:35 pm

Re: Javascript Error. window.addEvent is not a function?

Post by Nibinaear » Mon Jul 25, 2011 3:23 pm

I too am getting this problem on a custom template. As far as I can tell Joomla loads mootools anyway if it needs it so I don't know what to do. I'm trying to use ckforms module and the validation won't load. The code is as follows:

Code: Select all

window.addEvent('domready', function(){
	var myTips = new Tips('.ckform_tooltip2', {
		initialize:function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 250, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});


	var myForm = new FormCheck('ckform2', {
		fieldErrorClass : 'error',
		validateDisabled : true,
		display : {
			showErrors : 1,
			errorsLocation : 3,
			indicateErrors : 2,
			tipsPosition : 'right', 
			addClassErrorToField : true,
			scrollToFirst : true
		},
		alerts : {
			required:'This field is required.',
			number:'Please enter a valid number.',
			email:'Please enter a valid email: <br /><span>E.g. yourname&#64;domain.com</span>',
			url:'Please enter a valid url: <br /><span>E.g. http://www.domain.com</span>',
			confirm:'This field is different from %0',
			length_str:'The length is incorrect, it must be between %0 and %1',
			lengthmax:'The length is incorrect, it must be at max %0',
			lengthmin:'The length is incorrect, it must be at least %0',
			checkbox:'Please check the box',
			radios:'Please select a radio',
			select:'Please choose a value'
		}

	})

	$(document.body).getElements('.captcharefresh').addEvents({
		'click': function(){
			if($chk($('captchacode'))) { 
				$('captchacode').setProperty('src', 'index.php?option=com_ckforms&task=captcha&sid=' + Math.random());
			}
		}
	});

	
	
});



Locked

Return to “General Questions/New to Joomla! 1.5”