Open in New Window Link - IE Pop Up Blockers

Discussion in 'HTML & Website Design' started by ddzc, Aug 21, 2009.

  1. #1
    Hi all,

    I have some links on my website which I would like to open in a new window. Problem is, IE blocks them half of the time. Is there anyway around this..to avoid IE from blocking new windows for visitors of my site?


    Thanks
     
    ddzc, Aug 21, 2009 IP
  2. AssistantX

    AssistantX Peon

    Messages:
    173
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What coding method are you using to open the link in a new window?
     
    AssistantX, Aug 21, 2009 IP
  3. mpreyesmr

    mpreyesmr Banned

    Messages:
    175
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    When you say IE do you mean Internet Explorer, or does it mean something else? If you mean Internet Explorer, then change your browser to Firefox for faster search capabilities.
     
    Last edited: Aug 21, 2009
    mpreyesmr, Aug 21, 2009 IP
  4. AssistantX

    AssistantX Peon

    Messages:
    173
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    His question was not about finding a better browser than IE (Internet Explorer) nor did he state that he uses IE as his main browser. He simply asked how to solve an issue IE is having with his website. It is smart to test the functionality of his website in different browsers, and hopefully he does such.
     
    AssistantX, Aug 21, 2009 IP
  5. campolar

    campolar Peon

    Messages:
    2,683
    Likes Received:
    244
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If your using javascript to open a link in a new window, ur doing it all wrong!

    You can open a link in a new window by adding target="_blank" to the html. Like this:
    
    <a href="http://digitalpoint.com" target="_blank">Visit DigitalPoint.com!</a>
    
    HTML:
    That will open the page in a new window...
     
    campolar, Aug 21, 2009 IP
  6. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #6
    Using unobtrusive javascript is the right way to do it.

    That is invalid in all current standards. The 'target' attribute is correct only in limited contexts, and this is not one of them.

    In a simple form, the javascript:
    window.onload = target;
    
    function target() {
      var links = document.getElementsByTagName("a");
      for (var i = 0; i < links.length; i++) {
        if (links[i].className == "byebye") {
          links[i].onclick = function() {
            return !window.open(this.href);
          }
        }
      }
    }
    Code (markup):
    Give each link a class of "byebye" or whatever you prefer.

    A safer version (because error conditions are tested), and one that provides an alternative means of identifying the links:
    window.onload = function() {
        var links = document.getElementsByTagName("a");
        for (var i = 0; i < links.length; i++) {
          var rels = links[i].getAttribute("rel");
          if (rels) {
            var testpattern = new RegExp("external");
            if (testpattern.test(rels)) {
              links[i].onclick = function() {
                return !window.open(this.href);  
              }
            }
          }    
        }
      }
    Code (markup):
    This case calls for the links to have the 'rel' attribute set to 'external'. This version also has the advantage of not messing up on multiple rel values, e.g. rel="external nofollow".

    cheers,

    gary
     
    kk5st, Aug 22, 2009 IP