JavaScript: location.href to open in new window/tab?
window.open( ‘https://support.wwf.org.uk/earth_hour/index.php?type=individual’, ‘_blank’ // <- This is what makes it open in a new window. );
window.open( ‘https://support.wwf.org.uk/earth_hour/index.php?type=individual’, ‘_blank’ // <- This is what makes it open in a new window. );
According to the W3C, they are the same. In reality, for cross browser safety, you should use window.location rather than document.location. See: http://www.w3.org/TR/html/browsers.html#dom-location
Solving this problem is much more within reach nowadays. The HTML5 History API allows us to manipulate the location bar to display any URL within the current domain. function removeHash () { history.pushState(“”, document.title, window.location.pathname + window.location.search); } Working demo: http://jsfiddle.net/AndyE/ycmPt/show/ This works in Chrome 9, Firefox 4, Safari 5, Opera 11.50 and in IE … Read more