Jump to content

Error: Object doesn't support property or method


radar

Recommended Posts

Alright so I have an error with my ajax.js file.  which atm doesn't include any real ajax.  but im getting an error.

 

var headID = document.getElementsByTagName("head")[0];
loadScript('http://www.thesite.com/site/inc/js/tab.js', headID, 'text/javascript', 'script');
loadScript('http://www.the.com/site/inc/js/prototype.js', headID, 'text/javascript', 'script');

function loadScript(srcs, id, type, element) {
	var tabScript = document.createElement(element);
	tabScript.type = 'text/javascript';
	tabScript.src = srcs;
	id.appendChild(tabScript);
	tabScript.onload=alertArgument(srcs+' is loaded');
}
function UpdateEditorFormValue() { // FUNCTION TO ALLOW FCKEDITOR TO RUN WITH AJAX.
	for ( i = 0; i < parent.frames.length; ++i )
	if ( parent.frames[i].FCK )
	parent.frames[i].FCK.UpdateLinkedField();
}

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

// attach an event properly

function attachEvent(element, type, event)	{
  		if(element.attachEvent)	{
    		element.attachEvent('on' + type, event);
	} else {
		element.addEventListener(type, event, false);
	}
}

function alertArgument(myString)	{
  		alert(myString);
}

function attachBehaviors()	{
	attachEvent($('clickme'), "click", function()  {
    	new Ajax.Updater($('updateme'), 'ajax.html', {
   			method:'get', onComplete:function()	{
    			alertArgument('You clicked that thing!')
			}
		})
	});
}

// addLoadEvent(attachBehaviors);

 

its telling me the error is on line 36, which is

element.addEventListener(type, event, false);

 

however, when i remove the lines at the very top of this file to dynamically include protoype.js and tab.js it doesn't throw any errors...  any clue as to why?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.