2

Why I can't open a link in new tab on my mobile phone? But when I tried running my script on the PC Desktop, that link can be opened in new tab..

This is my script

if($data[$flag] == 1){
    echo "<li><a href=\"img2.php?x=".$fix[0][0]."&y=".$fix[1][0]."\">Sektor ".($flag + 1)."</a></li>\n";}
    $flag++;

any suggestions?

asyah28
  • 21
  • 3

2 Answers2

0

Try it.

 if($data[$flag] == 1){
 echo "<li><a href=\"img2.php?x=".$fix[0][0]."&y=".$fix[1][0]."\" target="blank">Sektor ".($flag + 1)."</a></li>\n";}
$flag++;

target="blank" use for open a link in new tab

Rajendra Yadav
  • 645
  • 3
  • 12
0

To force a link to open up in a new window/tab, you can use target="_blank" on the URL like this:

if($data[$flag] == 1){
    echo "<li><a href=\"img2.php?x=".$fix[0][0]."&y=".$fix[1][0]."\" target="_blank">Sektor ".($flag + 1)."</a></li>\n";}
    $flag++;

This should result in output that looks something like this:

<li><a href="img2.php?x=123&y=1456" target="_blank">Sektor 789</a></li>

Do bear in mind that the underscore in '_blank' is important.

Also worth mentioning is that this was depreciated from XHTML 1.1, but not from HTML5. This is a common misconception in the development community.

johnkavanagh
  • 4,614
  • 2
  • 25
  • 37