Page 1 of 1
Opening Link in new browser
Posted: Tue Apr 19, 2005 4:42 am
by mohson
can anyone show me how to alther this line of code so that the link opens in a new browser.
Code: Select all
<td>'. '<a href=http://'.$row->web_url.'>'.$row->orgname . '</a></td>
I knwo you need to use target"=_blank" in some form or another but advice would be greatly appreciated.
Posted: Tue Apr 19, 2005 5:17 am
by Chris Corbyn
Code: Select all
'<td>'. '<a href="http://'.$row->web_url.'>'.$row->orgname . '" target="_blank"</a></td>'
EDIT | Doh... didnt spot your syntax error

BTW - GOOGLE
Re: Opening Link in new browser
Posted: Tue Apr 19, 2005 5:20 am
by vigge89
mohson wrote:can anyone show me how to alther this line of code so that the link opens in a new browser.
Code: Select all
<td>'. '<a href=http://'.$row->web_url.'>'.$row->orgname . '</a></td>
I knwo you need to use target"=_blank" in some form or another but advice would be greatly appreciated.
Code: Select all
<?php echo '<td>'. '<a href="http://'.$row->web_url.'" target="blank">'.$row->orgname . '</a></td>';
Posted: Tue Apr 19, 2005 6:31 am
by mohson
maybe im completele missing something but botth of these methods result in a blank screen it must be that im putting in an extra ' or . heres the echo statement:
Code: Select all
echo "<tr bgcolor=\"$color\"><td>".$count . '</td>
<td>'.$row->org_id.'</td>
<td>'. '<a href=http://'.$row->web_url.'>'.$row->orgname . '</a></td>
<td>'. $row->notes .'</td>
<td><a href="editorganisations.html?org_id=' .$row->org_id. '">edit</tr>';
now how would I make the link open in a new browser?
i did google it bu the problem is how I incorporate it into my code.
Posted: Tue Apr 19, 2005 7:11 am
by feyd
make sure to quote the value of all attributes in tags. target is the proper way.
Posted: Tue Apr 19, 2005 9:08 am
by Todd_Z
XHTML compliant:
Code: Select all
$site = "www.google.com";
echo "<a href=\"$site\" onclick=\"window.open(this.href,'_blank');return false;\">";
Posted: Tue Apr 19, 2005 10:35 am
by vigge89
Todd_Z wrote:XHTML compliant:
Code: Select all
$site = "www.google.com";
echo "<a href="$site" onclick="window.open(this.href,'_blank');return false;">";
Not really, XHTML is designed too just be viewed in a single window (no frames either), that's why the target-attribute was removed. By using JavaScript, you're just cheating, if you rally want to use target="", consider going back to XHTML 1.0 Transitional.
Posted: Tue Apr 19, 2005 11:19 am
by timvw
The point is: the user should decide himself where/how a page/file is opened (more general handled). This makes the target attribute a bit useless, therefor i think it's removal was justified.
Imho, the javascript "work-around" is used by webmasters that still don't get that *i* and not them are in control.
Spend your time educating your users/manager so they know how the web really works instead of searching for things that are broken by design.
Posted: Fri Apr 22, 2005 5:48 am
by mohson
I dont think that this is correct, Ok I see the point that the user should be in control but it depends on the type of application - my users are working through a list of organisations and clicking on the orgs URL link one after the other, if you click on the link and it asks you the same quetion over and over again - wouldnt this be a bir irrtitating.
Actually if you only had to do it the once and then maybe this method would be ok.
Posted: Fri Apr 22, 2005 6:32 am
by Roja
vigge89 wrote:
Not really, XHTML is designed too just be viewed in a single window (no frames either), that's why the target-attribute was removed. By using JavaScript, you're just cheating, if you rally want to use target="", consider going back to XHTML 1.0 Transitional.
Yes and no.
Yes, it was their intention that authors not be the ones controlling people's browsing style (single-window, multi-window, etc). However, they explicitly discussed javascript as being
the correct replacement for that functionality. Its not cheating. Further, Transitional (by definition) is a stepping stone towards the final (strict), and will be phased out one day.
For a longer and more accurate writeup on how to use javascript to properly allow new windows in a xhtml-strict compliant site:
http://www.sitepoint.com/article/standa ... iant-world
By making it reliant on scripting, the user has control over whether to allow it or not. Simple.

Posted: Fri Apr 22, 2005 9:07 am
by neophyte
The sitepoint link was great. Thanks Roja...
Posted: Fri Apr 22, 2005 11:45 am
by Roja
neophyte wrote:The sitepoint link was great. Thanks Roja...
Sitepoint is sometimes a mixed bag, but they have some truly fantastic articles there. I'm working on an article submission to them this month, as a matter of fact, so hopefully soon I can point at my own article there.
