Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
this.href doesn't work in IE?
Old 10-15-2010, 04:02 PM this.href doesn't work in IE?
The_Anomaly's Avatar
Extreme Talker

Posts: 216
Location: Boston, Ma
Trades: 0
Using the following code, I get the correct results when in firefox, but I get undefined in IE. Any idea's?

(p.s. Sorry for the double post, this one really isn't related to my last post about onclick)

Code:
if(window.addEventListener){ // Firefox
              	document.links[i].addEventListener('click',function(){ openQuickWindow(this.href)}, false);
              } else { // IE
              	document.links[i].attachEvent('onclick', function(){ openQuickWindow(this.href)});
              }
The_Anomaly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-15-2010, 05:20 PM Re: this.href doesn't work in IE?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You need to use attachEvent Method for IE.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-15-2010, 05:22 PM Re: this.href doesn't work in IE?
Ultra Talker

Posts: 366
Name: Steve
Location: Miami, FL, Earth
Trades: 0
try this.getAttribute("href")
__________________
- Steve

President,
Please login or register to view this content. Registration is FREE
smoseley is offline
Reply With Quote
View Public Profile Visit smoseley's homepage!
 
Old 10-15-2010, 05:42 PM Re: this.href doesn't work in IE?
The_Anomaly's Avatar
Extreme Talker

Posts: 216
Location: Boston, Ma
Trades: 0
The getAttribute didn't work, but I did manage to find a workaround. I just pull in the url beforehand, and when it adds the listener to the function it has the actual url and not another JS variable.

Ends up looking like:
Code:
              // get the url for the link
              var passingUrl = document.links[i].href;

              // add listeners to each link
              if(window.addEventListener){ 
                // Firefox Listener
              	document.links[i].addEventListener('click',function(){ openQuickWindow(passingUrl)}, false);
              } else { 
                // IE Listener
              	document.links[i].attachEvent('onclick', function(){ openQuickWindow(passingUrl)});
              }
Thanks anyway!
The_Anomaly is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to this.href doesn't work in IE?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22830 seconds with 12 queries