I'm trying to design a site that makes use of
the window.open() javascript method by opening certain links in a new window with a specific pixel size and position onscreen, but Internet Explorer (with default security settings) blocks most attempts...Is there any way around this, to let IE know that its a legitimate site? Or does anyone know exactly what criteria IE looks at in determining popups?

All the pages opened are in the same site, under the same domain, and most of them are even served from the same directory. I just need to open them at a certain position on-screen, and have them be a certain size, and window.open() seems like the correct way to do this.

Using the target _blank attribute on a hyperlinked anchor tag is generally more likely to get past popup blockers...

That's not so good because you can't control the spawned window's size directly or open the new window automatically.

Some popup blockers would object to this kind of popup aswell O_O

Member Avatar for Dukane

NO there is no way to do that. If there was, then every site would do it so their popups dont get blocked!

I'm going to have to agree with Dukane, I looked for information but it looks like all popup windows are blocked.

i just dont understand why microsoft can't make even a simple web browser that works :(

well, the solution ive come up with is to just use target="_blank" links, then resize and relocate the window as it loads. its pretty hacky, but its the only thing that works in IE under default security settings. plus it has a degree of degredation for when javascript is disabled altogether.

thanks all, i appreciate the advice!

thanks all, i appreciate the advice!

Thank you. I like your solution by the way. Its creative.

If I turn the popup blocker on, it's because I don't want popups.

have you tried this?

<script>

function openpage(){
//set this to the file of the page.html
var pagefile="YOUR PAGE HTML HERE"

if (document.all)
pagewindow=window.open(pagefile,"","width=445,height=250")
else
pagewindow=window.open(pagefile,"","width=445,height=250,scrollbars")
}
</script>

<a href="javascript:openpage()">OPEN PAGE CLICK HERE</a>

always better to give folk a choice when it comes to popups if possible imo. :D

Why not just put an anchor tagged link on the page. If I want the extra page, I will click it. I don't need bamboozlers popping up to attract me to the link.

Yep thats the idea, it only pops up if the link is clicked (see above)

Why not just put an anchor tagged link on the page. If I want the extra page, I will click it. I don't need bamboozlers popping up to attract me to the link.

you misunderstand the original issue, being that ie blocks any use of window.open(), even in a link. meaning the following is still blocked, and by the default explorer configuration, no less:

<a href="javascript:window.open('newpage.html',params)">

you misunderstand the original issue, being that ie blocks any use of window.open(), even in a link. meaning the following is still blocked, and by the default explorer configuration, no less:

<a href="javascript:window.open('newpage.html',params)">

Are you sure its not your browser settings or something? My example above works perfectly in IE.

Are you sure its not your browser settings or something? My example above works perfectly in IE.

:shrug: it didnt work for me and like 10 other people, all on default ie settings (not sure about ie7)

A "better way" to write:

<a href="javascript:window.open('newpage.html',params)">

is:

<a href="newpage.html" onclick="window.open('newpage.html',params); return false;">

That way it satisfies both users with and withought JavaScript support on their browser.
(winout JS you wont be able to control the window anyway)

Using href="javascript:(some code)" will also write the returned object to the document window. So you'll get a blank page with "[object]" written in it in IE and in FF you get "[object Window]".

You could wrap the javascript in void() like:

<a href="javascript:void(window.open('newpage.html',params));">

but thats just adding unnecessary code.

I've never had a problem with popup blockers blocking window.open() in an "onclick" event..
On non-interactive events.. like window.onload or setTimeout .. yes.

I've never tries javascript:window.open in the href attribute. Maybe thats handled differently. You should probably try the onclick method, as its more standard.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.