0

How you you set the href attribute of an a element? This function works in FF, CHROME, and SAFARI but not in IE 8 or 9. In IE 8 or 9, both vars location and href only display "#"

    var getLocation = function(href) {
            l = document.createElement("a");
            l.href = href;
            // or l.setAttribute('href', href);
            confirm( "Location = " + l + " href = " +  href );
            return l;
   } 
rene
  • 41,474
  • 78
  • 114
  • 152
  • Do you need to `document.write` the element to the page? Just a guess. – brettkelly Oct 17 '12 at 19:37
  • What are you actually trying to do with this? The function's name is `getLocation`, but you return an element. And you also use the native `confirm` method. – Ian Oct 17 '12 at 19:41
  • The confirm is for debugging purpose only and I used to get the a element printed to the pop confirm box; I could have used alert or document.write(). – Mamadou Sylla Oct 17 '12 at 20:16

1 Answers1

0

From support side, I don't see any reason for not working. Is the JavaScript enabled in your IE8 and IE9? If you think yes, add an alert at the first line and check if this function is being called. If you get the alert right, can you please add alert(l.tagName) before updating the href and verify that an a(anchor) element was created?

Yogendra Singh
  • 33,927
  • 6
  • 63
  • 73