开发者

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 targe开发者_JAVA百科t='_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.


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;


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>


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' ">


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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜