Re: opening link in new window
| From: | Robert Cummings | Date: | Sat, 24 Jul 2010 06:44:15 +0000 |
| Subject: | Re: opening link in new window | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-307127@lists.php.net to get a copy of this message | ||
On 10-07-24 02:06 AM, Paul M Foster wrote:
On Sat, Jul 24, 2010 at 01:08:49AM -0400, Robert Cummings wrote:Canadian Federal Government requires that all public government websites validate to XHTML 1.0 strict. The validation is performed on what arrives at the browser, not what arrives at the PHP interpreter :) 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.On 10-07-24 12:58 AM, Paul M Foster wrote:You know, if you're going to sneak target="_blank" in the back way in order to avoid antagonizing the xhtml 1.0 deities, it seems like it'd be easier to just say: <?php echo '<A HREF="newwindow.html" TARGET="_blank">a new window</A>'; ?> Or, wait. With javascript, you're hacking the DOM. If you put my PHP above in the file, the offending code will arrive at the client browser. Will the xhtml 1.0 deities cast you into the pit of hell if this happens?On Fri, Jul 23, 2010 at 01:28:23AM -0400, David Mehler wrote: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.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.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"; } } } }