locked
href in javascript works in chrome but not in IE RRS feed

  • שאלה

  • I have this code:
     <link id="link1" type="image/vnd.microsoft.icon" href="images/favicon.ico" rel="shortcut icon"/>

    In a "script" I need to changed the "href" of the "link" , I tried sum types of codes:

    *
    document.getElementById('link1').href = "images/UserManagement.ico";

    *
     var newImage = new Image();
    newImage.src = 'images/UserManagement.ico?_=' + new Date().getTime();
     document.getElementById('link1').href = newImage.src; 

    *
     function changeFavicon(src) 
             {
                 var link = document.createElement('link'),
                 oldLink = document.getElementById('link1');
                 link.id = 'link1';
                 link.rel = 'shortcut icon';
                 link.href = src;
                 if (oldLink) {
                     document.getElementsByTagName('head')[0].removeChild(oldLink);
                 }
                 document.getElementsByTagName('head')[0].appendChild(link);
             }

    *
     function f2()
      {
       document.head || (document.head = document.getElementsByTagName('head')[1]);
        var currentlink = document.getElementById('link1');
        var link = document.createElement("link")
         link.id = 'link1';
         link.rel = 'shortcut icon';
         link.href = 'images/UserManagement.ico';
          if (currentlink)
              document.head.removeChild(currentlink);
          document.head.appendChild(link);
      }

    *
    document.getElementById('link1').setAttribute('href', "images/UserManagement.ico");


    all this codes work in chrome, but not in Internet Explorer!!!

    how can I change it that it should work in Internet Explorer?

    it's a lot of help for me!
    יום חמישי 13 יוני 2013 07:05