Using the window.open() function to create various windows

As we are all aware, when clicking on a submit button that contains an onClick(windown.open(...)) command, a new window is opened with the specified attributes. However, if you proceed to click on the parent window and then click on the 'submit' button again without closing the previous popup window, the same window gets replaced with new data.

Now, I am in need of a solution for the window.open() script to generate new windows each time it is clicked. This means that I should be able to click the parent "submit" button twice in a row and have two distinct child windows appear.

It seems like a simple issue, but I haven't been able to find a solution yet.

Answer №1

Assign a unique name to each new window you create.

window.open(websiteURL, UniqueWindowName)

Answer №2

Give this a shot, it will generate a new child element, try it out

let randomNumber = Math.floor((Math.random()*100)+1); 
 window.open(yoururl,"_blank",'PopUp',randomNumber,'scrollbars=1,menubar=0,resizable=1,width=850,height=500');

Answer №3

Take a look at this code snippet, it can assist you in opening a new window every time.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery example</title>
  <script src="jquery-3.5.1.js"></script>
</head>
<body>

<script>
$(document).on("click", "#button", function(event) {
    window.open("http://www.example.com", '_blank');
});

</script>
<input type="button" name="button" id="button">
</body>
</html>

Answer №4

When you click the popup button, a new window will open with dimensions of 1000x500.

This action triggers a fresh pop-up each time it is clicked.

Answer №5

My situation involved the browser blocking the pop-up window. I resolved this by giving permission for the pop-up window to appear.

https://i.sstatic.net/9TJUT.png

Answer №6

To prevent outbound links from opening multiple windows, it is important to enable the Track outbound links option. Simply include the below JavaScript code in your index.html file:

<script type="text/javascript>
  var clicky_custom = clicky_custom || {};
  clicky_custom.outbound_disable = 1;
</script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the correct way to iterate through a list of images fetched with getStaticProps and display them within the same component?

What is the proper way to map a list of images returned using getStaticProps? I had successfully implemented this by passing a prop to the gallery component in another page. However, I now want to consolidate all the getStaticProps code within the gallery ...

Tips on incorporating JavaScript files into Angular applications

Struggling to incorporate a JavaScript function into Angular, I have installed the plugin "npm I global payments-3ds". I copied the JavaScript files from node_modules and attempted to call them in my component. Below is an example: import { ...

Enhancing the node module of a subpackage within Lerna: A step-by-step guide

I recently integrated lerna into my workflow to streamline the installation of all node modules for multiple sub packages with just one command. Currently, I'm only utilizing the lerna bootstrap feature. Here's a snippet from my lerna.json: { & ...

Updating divs automatically using Ajax without refreshing the page is not functioning as intended

I'm having trouble understanding why this isn't functioning properly. My goal is to have the data from load.php displayed in the div sample. However, if the code is updated (for example, when pulling information from a database), I want only the ...

Using mongoDB to insert data followed by processing it with the process.next

Currently, I am in the process of inputting a list of 50k entries into my database. var tickets = [new Ticket(), new Ticket(), ...]; // 50k of them tickets.forEach(function (t, ind){ console.log(ind+1 + '/' + tickets.length); Ticket.find ...

extract data from a dropdown menu with playwright

I'm having a tough time figuring out how to select the "All" option in a dropdown menu and extract all the data from that page. I've found some related posts, but they don't quite match my scenario. The "select" element I'm working with ...

The pop-up fails to appear

Could you assist me in identifying the issue with my code? <script type="text/javascript"> function PopupCenter(pageURL, title,w,h) { var left = (screen.width/2)-(w/2); var top = (screen.height/2)- ...

How can I easily activate a C# class from an asp.net webpage?

I have three labels in my asp.net page: One with a default name for filtering Another filled with a list of names to click on for new filter A third one with a list of items to be filtered The content of the second and third labels is loaded by C# code ...

Is the button inactive until an action is taken?

In my coding project, I am working with two buttons. I am trying to figure out a way to disable the second button until the first button is clicked. Does anyone have any suggestions on how to achieve this using a combination of JavaScript and CSS? ...

Utilizing RxJs to flatMap objects containing observable properties

I'm having difficulty understanding a simple RxJs query that involves merging Observables that are wrapped inside an object. If I directly return the Observable from flatMap, it works fine but I also need to include the name in my output. How can I ac ...

Is there a way to retrieve the current map center coordinates using the getCenter function in @react-google-maps/api?

I am currently working with the GoogleMap component provided by @react-google-maps/api, but I am struggling to figure out how to obtain the latitude and longitude coordinates of the map's center after it has been moved. After some research, I came ac ...

Utilizing JavaScript Plugin to Fix Image Source URLs in Incorrect Directories

I'm struggling and really in need of some assistance. The issue I'm facing is with a plugin that has a JavaScript file containing an array of URLs pointing to a "texture" directory within the plugin for images. However, I keep encountering 404 e ...

The radio button is not appearing correctly in my HTML form

Seeking guidance as a newcomer to html and css. Looking to create a signup form using html and css, but encountering issues with the radio button not displaying in the browser. Unsure of the root cause of the problem. Any assistance would be greatly apprec ...

Is there a tool available that can convert the string "foo:blah" into JSON format?

My goal is to transform a human-readable list like the following: Enabled: Yes Server: example.com Port: 8080 Authenticated Proxy Enabled: 1 ... into a sanitized JSON object as shown below: { "Enabled": "Yes", "Server": "example.com", "Port" ...

What is preventing me from successfully sending form data using axios?

I've encountered an issue while consuming an API that requires a filter series to be sent within a formData. When I test it with Postman, everything works smoothly. I also tried using other libraries and had no problems. However, when attempting to do ...

Mastering the Art of Integrating API and JSON!

I've developed a bot using botkit and the Zendesk API to retrieve information. There's a function in my bot that prompts the user for a search term, searches for relevant information using the Zendesk API, and displays the result. I'm faci ...

Update a specific division

Looking for suggestions on how to automatically refresh a div? I'm currently developing a chess game and I need the div to reload every time one player updates data in the database. The game is almost complete, but there's an issue where Player ...

Switch the checkbox to a selection option

Is there a way to switch the selection method from checkboxes to a dropdown menu? $("input[name=koleso]:first").prop("checked", true); $('body').on('click', '.koleso label', function (e) { koles ...

Json error message displayed

I am currently learning javascript and working on creating a JSON code for a website. However, I am facing some error messages related to style, even though I have used style in the code. The specific error messages are as follows: 1: Bad template.json - E ...

updating SQL data source using parameter for listbox selection

I am working on a databound listbox in a SharePoint asp that autoposts for each selection. My goal is to save all the selected values in a parameter called @Product_Type2 and then use them in a SQL update query. I have managed to store the listbox values ...