Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 748237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:17:51+00:00 2026-05-14T14:17:51+00:00

In my javascript i want to open URL in new window with this method:

  • 0

In my javascript i want to open URL in new window with this method:

var win = window.open(url...);

How can i check this, not to open the same window and lose all inputted data.
For example, if i opened “www.musite.com/addproduct” URL in new window, input data, leave my work place. then i click open window again, new window open and i lost all my data.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:17:51+00:00Added an answer on May 14, 2026 at 2:17 pm

    The following will allow you to open the window only once:

    if (typeof win !== 'object') {
       win = window.open('http://www.google.com');
    }
    else {
       // Do nothing
    }
    

    As Sani suggested in another answer, it would be wise to keep track of when the window is closed, in order to be able to reopen it. You can listen for the window.onunload event in the popup window, as follows:

    window.onunload = function() {
       window.opener.win = undefined;
    }
    

    The onunload event handler will set the win global variable of the window that opened the popup to undefined, so you would be able to reopen the window.

    Be aware that due to the same origin policy, this will only work if the popup you open will be in the same domain as the parent window. In addition note that I’ve only tested the above in Firefox.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to do something like this: var w = window.open(javascript: makeAnAjaxRequest();); My question
I have a javascript function in which I want to open a new window
I want to open a new window by clicking on a marker using Google
I want to open a website, change its javascript, then show the website +
I am new to javascript.I want to move a car on path with arrows.I
How can allow this page to run on IIS server... It does not work
I have a web app which opens a new popup window with JavaScript and
I'm opening a new window via a javascript POST in response to a user
I'm opening a new window of a different domain from the host. I want
I want to pop up a new browser according to the url provided, for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.