Steven
Steven

Reputation: 25304

How to open a new window with target='_blank' ? My code doesn't work

$html=<<<html
<tr><td>$i.<a href="offtask.php?taskid=$taskid target='_blank' ">$title</a></td><td>$count</td><td class="nowrap">$locationtext</td></tr>
html;
echo $html;

How to open a new window in the code above? target='_blank' doesn't work.

Upvotes: 2

Views: 46500

Answers (6)

user54542
user54542

Reputation: 1

I have tried putting the target="_blank" in a number of places, this code comes from a rss reader but I don't want people to click and leave my site but to just open another tab

if($linked ) $msg = '<a href="'.$link.'" class="srssfetcher-link">'.$msg.'</a>'; // Puts a link to the posts

Upvotes: 0

Anto Alexander
Anto Alexander

Reputation: 53

Use The target="_blank" in front of the href in php

Upvotes: -2

GrayWizardx
GrayWizardx

Reputation: 21141

<a href="offtask.php?taskid=$taskid" target="_blank">

Upvotes: 1

zombat
zombat

Reputation: 94167

The reason it's not working is because you haven't separated your link attributes properly. Try outputting the href and the target with proper separation (ie, close your quotes).

Use this:

<a href="offtask.php?taskid=$taskid" target='_blank'>

instead of

<a href="offtask.php?taskid=$taskid target='_blank' ">

Upvotes: 1

Asaph
Asaph

Reputation: 162801

Your target attribute is stuck inside your href attribute. Try this:

$html=<<<html
<tr><td>$i.<a href="offtask.php?taskid=$taskid" target="_blank">$title</a></td><td>$count</td><td class="nowrap">$locationtext</td></tr>
html;
echo $html;

Upvotes: 10

Marius
Marius

Reputation: 58931

look at the code output by that code. It will look like this:

<tr><td>$i.<a href="offtask.php?taskid=$taskid target='_blank' ">$title</a></td><td>$count</td><td class="nowrap">$locationtext</td></tr>

and you want it to be

<tr><td>$i.<a href="offtask.php?taskid=$taskid" target="_blank">$title</a></td><td>$count</td><td class="nowrap">$locationtext</td></tr>

That is:

<a href="url" target="_blank">link</a>

Upvotes: 3

Related Questions