Change the window name in your two different calls:

function popitup(url,windowName) {
       newwindow=window.open(url,windowName,'height=200,width=150');
       if (window.focus) {newwindow.focus()}
       return false;
     }

windowName must be unique when you open a new window with same url otherwise the same window will be refreshed.

Answer from Umesh on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Window › open
Window: open() method - Web APIs | MDN
By default, window.open opens the page in a new tab. If popup is set to true, it requests that a minimal popup window be used. The UI features included in the popup window will be automatically decided by the browser, generally including an address bar only.
Discussions

Best practices for opening new window (pop up or pop under) with JavaScript
Is there a general consensus of best practices in regards to opening a new pop up (or pop under) window with JavaScript with pop up blockers? Yeah. Don't. More on reddit.com
🌐 r/javascript
10
0
April 12, 2011
Call pop up window always on top
Not real big with JS but am going through a bunch of books and tuts ect. For the moment I would like to know if there is a way to call up a pop up window from a button (have that done already) but have it stay on top of the main browser when you click back on the main browser. More on sitepoint.com
🌐 sitepoint.com
0
August 10, 2011
Standardize a popup's condition and UI opened by window.open
the reasoning behind the current condition for popup/window/tab More on github.com
🌐 github.com
55
June 15, 2020
Force popup windows to open in new tab?
Is it possible to force the new Edge browser to open all popup windows as tabs instead? I know there's a Chrome extension called "Open link in same tab, pop-up as tab" and that works but it's clunky, the window opens as a popup and then quickly… More on learn.microsoft.com
🌐 learn.microsoft.com
13
207
February 13, 2020
🌐
JavaScript.info
javascript.info › tutorial › frames and windows
Popups and window methods
A name of the new window. Each window has a window.name, and here we can specify which window to use for the popup. If there’s already a window with such name – the given URL opens in it, otherwise a new window is opened.
🌐
Reddit
reddit.com › r/javascript › best practices for opening new window (pop up or pop under) with javascript
r/javascript on Reddit: Best practices for opening new window (pop up or pop under) with JavaScript
April 12, 2011 -

Here at work, we do a fair bit of surveys on various sites via Survey Monkey. The MO has always been to do a pop under window - focus the parent, not the child/new window. I've stressed how I think this is slimey (hiding the new window), but it is what it is and that's that :)

Seems every time we have a survey, I'll get people coming to me because the new window is getting blocked by someone. I've looked at the code they're using and it's using the typical window.onload event. I tell them this is probably why they're getting blocked as the pop up blockers are no doubt seeing automatically opened windows as unwanted advertising. Because the window onload and onunload events have been so abused, this is why we have pop up blockers built into browsers as well as plugins.

I thought about perhaps using a timer to delay execution of the pop up from onload, but not sure if this will make any difference. I'm kind of guessing not but I haven't tested it yet. I can't really test it as it's another dept. that has access to the server, not me... I've also thought about using onmousemove to trigger it (user-triggered event) and then nulling that out but that seems even more stupid.

I've suggested adding static survey promos which would be user-triggered events as I think those might fare better in the world of pop up blockers - even though there's still no guarantee. So the user clicks to pop the new window.

I've also suggested removing JS from the equation altogether and having the promos link straight to Survey Monkey. The counter there is that they've lost where they are in our site (they could have deep-linked in). They can't just easily close the Survey Monkey window to pick back up where they left off in their task. Off the top of my head, I don't know if they can use their back button to backtrack from the end of the Survey Monkey survey, either.

Is there a general consensus of best practices in regards to opening a new pop up (or pop under) window with JavaScript with pop up blockers?

🌐
W3Schools
w3schools.com › jsref › met_win_open.asp
Window open() Method
The open() method opens a new browser window, or a new tab, depending on your browser settings and the parameter values.
Find elsewhere
🌐
Chrome Web Store
chromewebstore.google.com › detail › popup-window › nnlippelgfbglbhiccffmnmlnhmbjjpe
Popup window - Chrome Web Store
Add a keyboard shortcut to move the current tab to a new window or popup. ... Average rating 4.1 out of 5 stars. Learn more about results and reviews. A simple extension that allows tabs to be opened in a separate minimal window.
🌐
SitePoint
sitepoint.com › javascript
Call pop up window always on top
August 10, 2011 - Not real big with JS but am going through a bunch of books and tuts ect. For the moment I would like to know if there is a way to call up a pop up window from a button (have that done already) but have it stay on top of…
🌐
GitHub
github.com › whatwg › html › issues › 5872
Standardize a popup's condition and UI opened by window.open · Issue #5872 · whatwg/html
June 15, 2020 - The behavior of window.open differs between browsers, for: the condition to choose the target based on features parameter, from · new popup window · new normal window ·
Author   arai-a
🌐
Oracle
forums.oracle.com › ords › apexds › post › opening-a-new-window-from-a-popup-window-1220
Opening a new window from a popup window
September 16, 2009 - Hi I have a button (button 'A') on page 1 that when a user clicks opens page 2 in a pop up window. In page 2, I have another button (button 'B') that when the user clicks must open a page (in another...
🌐
Chrome Developers
developer.chrome.com › blog › new origin trial for fullscreen popup windows
New origin trial for fullscreen popup windows | Blog | Chrome for Developers
October 9, 2023 - From the main app window, calling the window.open() method that requires a user gesture like the click on an Open popup window button.
🌐
SitePoint
sitepoint.com › blog › javascript › js code snippet to open a popup window
js code snippet to open a popup window — SitePoint
February 13, 2024 - Here is a basic example: var myWindow = window.open("", "myWindow", "width=200,height=100"); myWindow.document.write("<p>This is 'myWindow'</p>"); In this example, the window.open() method takes three parameters: the URL of the page to open (left blank here to create an empty window), the name of the window, and a string indicating the window’s features (like its width and height). You can control the size and position of the popup window by specifying them in the third parameter of the window.open() method.
🌐
Caspio
forums.caspio.com › bridge framework › general questions
How do I code a JavaScript pop up window - General Questions - Caspio Community Forums
December 13, 2017 - What is the best and easiest way to have a modal window pop up in JavaScript code? I have a function in JavaScript where I would like to put a modal pop up window code in so what I know it is being hit. I did a search engine search on the internet for examples of this but everything I found was a...
🌐
Super Dev Resources
superdevresources.com › home › blog › development › how to open links in a popup window
How to Open Links in a Popup Window - Super Dev Resources
June 18, 2020 - In order to open them in a new window, we add target="_blank" attribute to links. However to open the links in a separate popup window, we can make use of the onclick property and specifying a inline JavaScript code window.open as shown below.
🌐
Tek-Tips
tek-tips.com › home › forums › software › programmers › web development › javascript
Bringing an existing popup to front without refreshing... | Tek-Tips
December 20, 2005 - If you find that not all browsers support onunload, then you should set up a timer in the parent window that polls all windows opened by it (see my FAQ on closing all child windows on how to keep track of windows opened), and checks their "closed" status. If closed, you can focus the parent window (you'll need to them remove the window reference from the array mentioned in the FAQ, otherwise the parent window will be forever getting focus). Hope this helps, Dan [tt]Dan's Page [blue]@[/blue] Code Couch ... Thanks for your input BRPS (love that ID) The problem is automatically bringing Popup #1 back into focus each time the secondary popups are closed, not bring focus back to the parent window.
🌐
HTML.com
html.com › javascript › popup-windows
Popup Windows Made Easy: Here's The JavaScript Code To Copy And Paste »
March 19, 2020 - Line 7 is the real kernel of the whole function — this is where the popup is actually opened. window.open() takes three arguments. The first is the URL to open in the popup. In our script we use the mylink variable. The second is a unique name of the popup — we use the windowname variable.
🌐
University of Pennsylvania
isc.upenn.edu › resources › configuring-your-web-browser-allow-pop-windows
Configuring your web browser to allow pop-up windows | Information Systems & Computing
The Pop-up Blocker Settings dialog box opens. Right-click in the Address of website to allow: field, then choose the Paste command. Notes: Pasting the web address of a page you wish to allow pop-ups is recommended, rather than typing the generic main web address. For example, you might visit www.example.com/requirepopup.html, but the page is actually hosted at popup.example.com/forms/popupform.html.