PDA

View Full Version : How to open _blank page links?



winpeace
11-04-2007, 02:45 PM
1) Script Title: Random iframe content

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/randomiframe.htm

3) Describe problem:
//Specify random URLs to display inside iframe
var randomcontent=new Array()
randomcontent[0]="http://www.dynamicdrive.com"
.
.
.

How to open _blank page(a new window) links?(for example:"http://www.dynamicdrive.com")

jscheuer1
11-04-2007, 04:23 PM
window.open('http://www.dynamicdrive.com','_blank');

But most browser will block that unless it is used like so as part of the body of the page:


<a href="http://www.dynamicdrive.com"
onclick="window.open(this.href,'_blank');return false;"
>Dynamic Drive</a>

That's because all modern browsers generally block pop ups not directly initiated by the user. Some even block those.