0

I want to open a page in new tab as _blank in anchor tag.But window.location will open in same page.

   if(isset($_REQUEST['add']))
   {
    function re()
      {
       echo ("<SCRIPT LANGUAGE='JavaScript'>
       window.location='admin_register.php';
       </SCRIPT>"); 
      }
   }

3 Answers 3

1

Please try this using jquery

var url = "http://google.com";
$("<a>").attr("href", url).attr("target", "_blank")[0].click();
Sign up to request clarification or add additional context in comments.

Comments

0

This problem is solved with this code.

 <button name="add"  class="admin" onclick="admin()">Add Admin</button>
 script>
 function admin() {
   window.open("admin_register.php");
  }  
 </script>

Comments

0

Try with window.open

 if(isset($_REQUEST['add']))
   {
    function re()
      {
       echo ("<SCRIPT LANGUAGE='JavaScript'>
       window.open('admin_register.php','_blank');
       </SCRIPT>"); 
      }
   }

OR

<a href="#something" onclick="window.open('admin_register.php','_blank');">Click Here</a>

BUTTON ?

<button onclick="window.open('admin_register.php','_blank');">Click here</button>

2 Comments

I want to use button instead of anchor tag
@saru added button. Your question content doesn't say anything about a button: "I want to open a page in new tab as _blank in anchor tag". However I edited the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.