Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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>
<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>
like image 405
RedSun Avatar asked Sep 30 '13 16:09

RedSun


People also ask

Can I make pop-ups open in a new tab instead of a separate window How?

If you don't want to use those extensions, then the most simple solution is to Ctrl + Click the link you think it's a pop-up: it will be open as a new tab. That requires predicting in advance what the pop-ups will be and also doesn't work for Javascript links.

How do I force the edges to open in a new tab?

How Do I Get Edge to Open Links in a New Tab? If you're looking for a quick workaround, you can hold the Ctrl key and then click the respective link to open it in a new tab.

How do I get Firefox to open popups with new tabs?

Popup To Tab by em_te Simply right-click on any tab and choose 'Move Popups Here'.


1 Answers

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

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

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

like image 51
fray88 Avatar answered Sep 22 '22 01:09

fray88