jquery-urlinternal
jquery-urlinternal copied to clipboard
IE says "method not found" on A=(z||"").match
This piece of code: A=(z||"").match
It looks like IE doesn't like z||"" - I replaced with just "" for ex. and it doesn't complain. Obviously we need another solution :)
Can you show me where in your code this is occurring? I've never encountered this error.
It's a mix of jQuery and Prototype (in rails) so maybe I need to take the "content" of element explicitely. Here is where I use the isUrlInternal
initialize: function(){
$$('div#content').first().observe('click', (function(event) { this.get_hash(event); } ).bind(this) );
},
get_hash: function(event) {
itself = event.element().tagName == 'A';
itsparent = event.element().parentNode.tagName == 'A';
itsparentsparent = event.element().parentNode.parentNode.tagName == 'A';
if ( (itself || itsparent || itsparentsparent)) {
var element = (itself) ? event.element() : ( (itsparent) ? event.element().parentNode : event.element().parentNode.parentNode);
if (jQuery.isUrlInternal(element)) {
and this is where IE complains that "element" does not have the method "match" I think
Take a look at the documentation, and you'll see that jQuery.isUrlInternal() expects a url as its argument, not an element.
Of course, you can use something like this if you really want: if ( jQuery(element).urlInternal().length ) { ... }
element.href
oh. crap. sorry. I feel very stupid. closing this one.
Only IE complains though. So how should I send the URL of the element?
The method expects a string. So if you're not specifying a string, but browsers are not complaining, they may be casting your value into a string. IE might not be doing that.
Pass in a string!