[BNM] [Bulk] Re: XHTML strict New Window

robert stevens Robs_here at btinternet.com
Tue Mar 13 11:59:07 GMT 2007


Thanks Dan!

Umm, I'm no JS maestro here. You don't mean to change anything in my HTML
links do you? They can stay like this:
<a href="document.html" rel="external">external link</a>

This is how the jS is now
------------------------------
function externalLinks() {
  if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors.length; i++) {
    var anchor = anchors[i];
    if (anchor.getAttribute("href") &&
        anchor.getAttribute("rel") == "external")
      anchor.target = "_blank";
  } 
 } 
 window.onload = externalLinks;
-------------------------------

Do you mean to write an additional function?

Thanks, 

Rob

-------------------------------
> Dan Eastwell13/3/07 11:48 am daneastwell at gmail.com

> Try as well as rel="external" as your HTML trigger, using the following:
> 
> externalWindow("a[@rel='external']");
> 
> in your document.ready
> 
> and
> 
> function externalWindow(theElement){
> $(theElement).click(function() {
> window.open(this.href);
> return false;
>   });
> }
> 
> This should work.
> 
> On 3/13/07, robert stevens <Robs_here at btinternet.com> wrote:
>> Dear all,
>> 
>> I'm having to use pop up windows for external links (and a few internal
>> too). As you XHTML strict peeps will know, using target="_blank" in the HTML
>> for this will fail XHTML strict in the WC3 Validator.
>> 
>> Have researched some simple JavaScript options for this. One that kept
>> cropping up, and I have tried to use, is this:
>> http://www.sitepoint.com/article/standards-compliant-world
>> 
>> However, in Safari and Firefox (OS X) it doesn't open a new window.
>> It's possible I've made an error. Does anyone know a robust standards
>> compliant new window opener that will work in Safari and Firefox (Mac)?
>> 
>> Many thanks,
>> 
>> Rob
>> 
>> --
>> 
>> BNM Subscribe/Unsubscribe:
>> http://lists.wessexnetworks.com/cgi-bin/mailman/options/bnmlist/
>> BNM info/archives:
>> http://www.brightonnewmedia.org/
>> 
>> BNM archive search:
>> http://www.roddis.org/bnm/search.php
>> 
>> BNM powered by Wessex Networks:
>> http://www.wessexnetworks.com
>> 
> 




More information about the BNMlist mailing list. Powered by Wessex Networks