Home » Php » javascript – I want to open a new tab instead of a popup window

javascript – I want to open a new tab instead of a popup window

Posted by: admin July 12, 2020 Leave a comment


I am trying to open a new tab.
But Window.open() is opening up popup window.

I want to open hello.php file in a new tab.
But it is opening up in a new popup window.

<!DOCTYPE html>
<script language="javascript">

//status="Right Click Disabled";

function disableclick(event)
     return false;    
<body oncontextmenu="return false">

<form action="" method="POST" oncontextmenu="return false">

<b>Enter Username:</b><input type="text" name="username" value=""/><br>

<b>Enter Password: </b><input type="password" name="password" value=""/><br>

<input type="submit" value="submit" name="submit"/>
<input type="reset" value="reset" name="reset"/>



if (isset($_POST['submit'])) 


mysql_connect("localhost", "root", "") or die(mysql_error()); 

mysql_select_db("demo") or die(mysql_error()); 

$result=mysql_query("select * from employees where name='$username' and pass='$password'") 
 or die(mysql_error()); 

print "<br/>";
print "<b>Incorrect Username/Password!!!</b>";

mysql_query("Create table $username(Question_No varchar(10),Selected_Answer varchar(10))") 
 or die(mysql_error());  

print "<br/>";
print "<b>Login successful!!!</b><br/><br/>";

print "<script>window.open('hello.php?username=$username')</script>";

print "<script>window.close('userdetails.php')</script>";


How to&Answers:

In case it could be a javascript issue about override functions, do that:

(function(window, undefined){
    var win = window.open('your_url', '_blank');

That should make you can’t use functions from other javascript code out of your function(window, undefined) wrapper-


You can do it by window.open(url, '_blank');


assign the url to open to a tag’s href attribute, with target=”_blank”, then trigger link click when you want. Example:

<a id="myLink" href="hello.php?username=<?php echo $username; ?>" target="_blank">

Then, call a js function to trigger link click