Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window.Open and IE

Status
Not open for further replies.

Maldini

Technical User
Nov 10, 2002
55
0
0
GB
Hi,

Just stumbled upon this problem and really have no idea how to overcome it.
I'm using javascript to open new windows via the window.open technique. I've been testing with Mozilla Firefox all the time along and the new windows open perfectly in it.
However, once I tried testing in IE, no windows are opened at all. In fact, nothing happens, no errors, no nothing.

This is a sample of what I'm using:

window.open(str,'New Window','left=200,top=100,width=700,height=350,resizable=yes');

Is this a known issue with IE6? Or is there something in my javascript thats incompatible with IE6?

Thanks.
Maldini
 
if you're calling it from an involuntary action (onload, for example), this may be the reason.

otherwise, I suspect your code looks like this:

Code:
<a href=#" onclick="window.open(...)">

change it to this:

Code:
<a href=#" onclick="window.open(...); return false;">

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Sorry, I guess I was unclear in the first post.

I've got this placed in an external js file, held in a function. So an example is like this:

function ProdWin(str) {
window.open(str,'Prod',,'left=200,top=100,width=700,height=350,resizable=yes');
}

And from my asp pages, I'm calling these functions from text links or buttons, like:

<a href="javascript:prodWin('Prod.asp?ProdID=2')>Link</a>

Or

<Input Type-"Button"... onClick="ProdWin('Prod.asp?ProdID=2')">

I'm finding its just these ones involved in opening new windows that don't work. All javascript used for showing/hiding divisions or doing calculations work fine.

Thanks again,
Puzzled Maldini.
 
couple things...

Code:
window.open(str,'Prod',[red]'w'[/red],'left=200,top=100,width=700,height=350,resizable=yes');

and, I'd put the call to the function in the onclick event of the <a> rather than the href, as I described above.

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 

Shouldn't that be:

Code:
window.open(str, 'Prod', 'left=200,top=100,width=700,height=350,resizable=yes');

?

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
What is that 3rd parameter your example uses, cLFlaVA? I looked window.open up on Google, and both MSDN and Mozilla have the window features as the 3rd on the list. MSDN (technically JScript) has a 4th parameter, but Mozilla didn't mention it.

Lee
 
Thought maybe I missed some new development that happened recently, BRPS. :)#

Lee
 
Oops, sorry, that was a one off typo in my javascript, not meant to be a 3rd parameter in there.
Been experimenting with different combinations so far, moving between the onClicks and hrefs but still no success.
 

You should make sure your window names do NOT contain spaces. This can cause problems, I believe.

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Show us the code you have now. Copy and paste it in, don't type it in again or give us a sample that's not the real thing.

Lee
 

After reading and re-reading this thread, my money is definately on the space in the window name causing the problem:

Code:
window.open(str, 'New Window','left=200,top=100,width=700,height=350,resizable=yes');

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
I know for certain that a space in the second argument won't work in IE. I struggled with this same problem when writting code for my website. Remove the space, and it should work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top