I have a form with action e.g. register.php
I also have a Google group API link -
in short... Is there any PHP function for open page in new tab; on page load...
I have a form with action e.g. register.php
I also have a Google group API link -
in short... Is there any PHP function for open page in new tab; on page load...
Use the target
attribute on your anchor
tag with the _blank
value.
Example:
<a href="http://google.com" target="_blank">Click Me!</a>
You can write JavaScript code in your file .
Put following code in your client side file:
<script>
window.onload = function(){
window.open(url, "_blank"); // will open new tab on window.onload
}
</script>
using jQuery.ready
<script>
$(document).ready(function(){
window.open(url, "_blank"); // will open new tab on document ready
});
</script>
You can use both PHP and javascript. Perform your php codes in the backend and redirect to a php page. On the php page you redirected to add the code below:
<?php if(condition_to_check_for){ ?>
<script type="text/javascript">
window.open('url_goes_here', '_blank');
</script>
<? } ?>
You can simply use target="_blank"
to open a page in a new tab
<a href="whatever.php" target="_blank">Opens On Another Tab</a>
Or you can simply use a javascript for onload
<body onload="window.open(url, '_blank');">
This is a trick,
function OpenInNewTab(url) {
var win = window.open(url, '_blank');
win.focus();
}
In most cases, this should happen directly in the onclick handler for the link to prevent pop-up blockers, and the default "new window" behavior. You could do it this way, or by adding an event listener to your DOM object.
<div onclick="OpenInNewTab();">Something To Click On</div>