1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Doesn't work in IE

Discussion in 'JavaScript' started by qwikad.com, Jul 8, 2019.

  1. #1
    This little function opens links in a new window in all browsers except IE / Edge:
    
    function externalLinks() {
    for(var c = document.getElementsByTagName("a"), a = 0;a < c.length;a++)
    { var b = c[a]; b.getAttribute("href") && b.hostname !== location.hostname && (b.target = "_blank") } } ; externalLinks();
    
    Code (markup):
    Does anyone know why?
     
    qwikad.com, Jul 8, 2019 IP
  2. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #2
    Got it working by changing b.hostname to b.href.hostname
     
    qwikad.com, Jul 8, 2019 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #3
    Probably WAY too late, but did you REALLY mean to assign b.target to __blank, or is that supposed to be ==?
     
    deathshadow, Jul 31, 2019 IP