I having some problem to open page in a new tab using php. Actually once a button is clicked on the menu bar it should open in a new tab. Can anyone tell me how to do this.
Asked
Active
Viewed 1,902 times
0
-
You'd just need simple javascript, no need for jquery/php – Curtis W Apr 23 '14 at 03:39
3 Answers
2
There is nothing about PHP.
Example for links:
<a href="page.html" target="_blank">Click</a>
Example for button:
<input type="button" value="Click" onClick="javascript:window.open('page.html', '_blank');" />

Paul Denisevich
- 2,329
- 14
- 19
-
-
-
-
@user3536613 I've updated your code, it works, take a look: http://jsfiddle.net/UL6zu/1/ - top links are now okay and active – Paul Denisevich Apr 23 '14 at 04:13
-
-
-
well i have tried but still i have to right click on it then only it opens in a new tab.. if i click on it nothing happens – raaj5671 Apr 23 '14 at 04:20
-
So the problem is in the rest of your code. It jsFiddle works for you then my code is OK. – Paul Denisevich Apr 23 '14 at 04:31
0
You can do like it
function openWindow( url )
{
window.open(url, '_blank');
window.focus();
}
<a href="http://www.example.com/" onclick="javascript:openWindow(this.href);return false;">Click Me</a>
Reference: Open new tab in javascript

Community
- 1
- 1

fanfan1609
- 179
- 2
- 8
-
well this works but i have to right click on my browser to open it in a new tab.. are there any ways. – raaj5671 Apr 23 '14 at 04:02
0
Nothing to do more then put your target ="_blank"
Example:
window.open(url, '_blank');
show demo. Fiddle

Kaushal Khamar
- 2,097
- 1
- 17
- 23