-4

How To Open view.php in new tab.

$url=mysql_result($result, $i, 'url');
echo '<td><a href="view.php?url='.$url.'" >Click Here</td>';
Chris Bloom
  • 3,526
  • 1
  • 33
  • 47

1 Answers1

1

You have to add target attribute to the anchor tag (<a>) and assign the attribute value as _blank to open in a new tab

$url=mysql_result($result, $i, 'url');
echo '<td><a target="_blank" href="view.php?url='.$url.'" >Click Here</td>';

Change your code to above code and the page will be opened in new tab on clicking the link.

AeJey
  • 1,447
  • 20
  • 40
  • that's not true. it depends on the browser and browser-settings. `target="_blank"` originally tells the browser to open the link in a new browser window. but you can't explicitly tell the browser to open the link in a new tab. – low_rents Sep 10 '14 at 06:30
  • Thank you for pointing it out. But it will work (will open in new tab ) in modern browsers. So i think it will be the best option since there is no option particularly for 'new tab' – AeJey Sep 10 '14 at 06:41
  • sorry to disappoint you, but no - you can't even rely on that in modern browsers. for example in an IE10 with standard settings, a javascript `window.open()` with the `_blank` target will open in a new window. it's more a browser setting thing than anything else. or in other words: the introducing of tabs to browsers killed the nonambiguous meaning which `_blank` had in that context. and still it got never replaced, removed or "corrected" by the W3C so far. – low_rents Sep 10 '14 at 07:48