Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
nodeType is null or not an object?
2 Posts
nodeType is null or not an object?

Like the other thread, I'm going to point you to the prototype docs: http://prototypejs.org/api/event/observe If you use observe then your callback will be sent an event object that has already been extended.

Hello,

I use prototype.js for my website, I wrote a following function which gives me the clicked anchor tag and showing appropriate page for that clicked link.

function bodyOnClick(eventClick) {

var e = Event.extend(eventClick);
var obj = Event.element(e);

if(obj == null || obj == undefined) return;
if(obj.nodeName == "A" && obj.onclick == null)
{
    absoluteUrl = obj.href;
    var regexp = /(.*)\/\#(.*)/;
    var tempRelativeUrl = regexp.exec(absoluteUrl);
    relativeUrl = "#" + tempRelativeUrl[2];
    showPane(parseLocation(relativeUrl), true, false, false);
    Event.stop(eventClick);
    return false;
}
return true;

}

I used Event.element(e) but it throws error in both IE 7 and FireFox 3 In IE7-- Error is "nodeType is null or not an object" and In FireFox 3--- "node is undefined".

When i debug this code It shows me error in prototype.js file for following lines

3861 if (node.nodeType == Node.TEXT_NODE) node = node.parentNode; 3862 return Element.extend(node); 3863 },

I dont understand where is the problem? please can any one tell me?

Thanks, Vikas

2 Posts
Login to add your message