views:

213

answers:

4

Hello,

does anybody know such a problem, window.open()do not work with Firefox suddenly.

<a href="javascript: void(0)" 
   onclick="window.open('popup.html', 
  'windowname1', 
  'width=200, height=77'); 
   return false;">Click here for simple popup window</a>

this always open in a new window (or a new tab), but not open in a popup window.

Thanks,

+2  A: 

if you want to open a pop up window, it's alert('message'). window.open always opened a full window/tab.

(Edited: Even if you specify width/height, most browser allow you to allow javascript but not allow it to resize your windows, and firefox also allows you to force new windows to new tabs)

Kasumi
A: 

Maybe you need to add some extra variables to the window.open() method

<a href="#" 
   onclick="window.open('http://url','windowname1', 'width=200,height=100,scrollbars=yes,toolbar=yes,location=yes'); return false">Link</a>
Robert Cabri
A: 
Add attribute TARGET="_blank" to <a> tag as below. This will open as popup`<a TARGET="_blank" href="javascript: void(0)"  .............</a>`
valli
this will not open a popup. Just a new page. The Target element is only allowed in the HTML 4 standard, not in XHTML standard
Robert Cabri
+2  A: 

I find that your code works perfectly. I pasted it into a new HTML page, clicked the link (using Firefox) and voila, new window.

My guess is that you're trying to use the link from a window that already has the name of the window you're trying to create. If the page is presented in a window whose name is already "windowname1", then the browser will put the results of you javascript action in that window instead of popping up a new one.

For example, if the code above is on a page named "popup.html" (the name of the file you open in window.open statement) then it will work the first time (since you haven't yet created a window named "windowname1". Then if you try to click the link again in the new window that popped up (whose name is windowname1), it will just refresh the same window instead of popping a new one.

I don't see why this would happen in firefox only though. I found identical results in Firefox, Chrome, and IE.

Paul