I want to open a new tab instead of a popup

I am trying to open a new tab. But it Window.open()opens a popup.

I want to open the file hello.phpin a new tab. But it opens in a new popup.

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

document.onmousedown=disableclick;
//status="Right Click Disabled";

function disableclick(event)
{
  if(event.button==2)
   {
     //alert(status);
     return false;    
   }
}
</script>
</head>
<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"/>

</form>

<?php


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

$username=$_POST['username'];
$password=$_POST['password'];

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()); 


if(mysql_num_rows($result)==0)
{
print "<br/>";
print "<b>Incorrect Username/Password!!!</b>";
}
else
{


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>";
}

}
?>

</body>
</html>
+4
source share
3 answers

In case this might be a javascript issue for override functions, do the following:

<script>
(function(window, undefined){
    var win = window.open('your_url', '_blank');
    win.focus();
})(window);
</script>

This should make you not use functions from other javascript code from your shell (windows, undefined) -

+7
source

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

0
source

assign a url to open the href attribute of the tag, with target = "_ blank", and then call the link whenever you want. Example:

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

Then call js function to call link to link

document.getElementById('myLink').click();
0
source

All Articles