Link to home
Start Free TrialLog in
Avatar of tdiscover
tdiscover

asked on

Error when using Event.observe

I copied some code from my friends website (with his permission of course). It works fine on his site but on my website IE gives the error: 'Event' is undefined. IE says the error is for the line "Event.observe(window, 'load', init, false);". Oh and it doesn't work in firefox either.

Thanks for your help
Event.observe(window, 'load', init, false);
 
function init(){
	//images
	makeEditable('campaignIMG');
	makeEditable('secondaryCampaignIMG');
	makeEditable('nature');
	makeEditable('culture');
	makeEditable('outback');
}
 
function makeEditable(id){
	Event.observe(id, 'click', function(){showAsEditing($(id))});
	Event.observe(id, 'mouseover', function(){showAsEditable($(id), false)});
	Event.observe(id, 'mouseout', function(){showAsEditable($(id), true)});
}
 
function showAsEditable(obj, clear){
	if (!clear){
		Element.addClassName(obj, 'editable');
	}else{
		Element.removeClassName(obj, 'editable');
	}
}
 
function showAsEditing(obj){
	Element.hide(obj);
}

Open in new window

Avatar of hielo
hielo
Flag of Wallis and Futuna image

I suspect your friends site uses prototype, which is where Event.observe is defined. If not prototype, it would be a similar javascript framework. At any rate, refer to his site to see where it is defined.
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tdiscover
tdiscover

ASKER

ok, I'm giving it a go now..
Great, thanks Hielo! Haha, I feel rather silly because it was such a simple thing.

Cheers!