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?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.