skip to Main Content

I am trying to create a new window using javascript but it create a new tab instead of a new window

    const raiseInvoiceClicked = () => {
        let params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,
width=0,height=0,left=-1000,top=-1000`;

        const newWindow = window.open("http://localhost:3000", '_blank', "height=200,width=200", 'noopener,noreferrer')
        if (newWindow) newWindow.opener = null
    }

2

Answers


  1. f you want to create a new tab in React.js when a user clicks a link or a button instead of opening a new window, you can achieve this by using the target="_blank" attribute in the link or by programmatically opening a new tab using JavaScript. Here are both approaches:
    
    Using target="_blank" in a Link:
    
        const raiseInvoiceClicked = () => {
      const windowFeatures = "scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=200,height=200,left=-1000,top=-1000";
    
      const newWindow = window.open("http://localhost:3000", "_blank", windowFeatures);
    
      if (newWindow) {
        newWindow.opener = null;
      }
    };
    
    Login or Signup to reply.
  2. const secondScreen = window.open("https://www.google.com",'','width=200px,height=200px');
    

    will open google in new window and size will be 200×200

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search