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
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.
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.
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...
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