On 10-07-24 12:58 AM, Paul M Foster wrote:
On Fri, Jul 23, 2010 at 01:28:23AM -0400, David Mehler wrote:
Hello,
I've got a page with an external link. I'd like to open it in a new
window, but i'm using the xhtml 1.0 strict dtd so this isn't possible.
I was wondering if php could pull this off? Failing that, and not
really wanting to go there, would javascript work for this?
Thanks.
Dave.
I take it
<A HREF="newwindow.html" TARGET="_blank">a new window</A>
is not part of the xhtml 1.0 strict dtd? Because I recently solved this
problem using the above syntax.
The GP is correct, target="_blank" is not valid XHTML 1.0 strict.
Here's some JavaScript to put in your page and run once the page
completes loading. It looks for anchors having rel="nofollow" and
rel="external" attributes in anchors and adds a target="_blank" attribute.
function bahHumbugExternalLinks()
{
if( !document.getElementsByTagName )
{
return;
}
var anchor = null;
var anchors = document.getElementsByTagName( 'a' );
for( var i = 0; i < anchors.length; i++ )
{
anchor = anchors[i];
if( anchor.getAttribute( 'href' ) )
{
if( anchor.getAttribute( 'rel' ) == 'nofollow'
||
anchor.getAttribute( 'rel' ) == 'external' )
{
anchor.target = "_blank";
}
}
}
}
Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php