Andy Skelton <[EMAIL PROTECTED]> wrote:
|  The option in quesion, "open link in new window," will probably not
|  remain as a way to use the target attribute. If someone would like to
|  research and suggest a 100% in-line solution, such as an onclick
|  function that doesn't have to be pre-defined, and it's valid and
|  doesn't break any browsers, we'll use that instead of simply removing
|  the option.

|  Anyone interested?
 
yes well, the other approach will be _javascript_ dependent. the links can be
tagged by the 'rel' attribute and marked as 'external' and then a _javascript_
function can be called on page load to parse whole (x)HTML code to
make the links with 'rel="external"' to be opened in a new window.
 
I posted a working JS function in the hackers list thread
"XHTML Strict compliant replacement for target=_new" sometime back which
I post again below
 
~~~~~~~~~
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. false;};
        }
    }
}
window.>~~~~~~~~~
an example link would be
~~~~~~~~~
<a href="" rel="external">Google</a>
~~~~~~~~~
 
though I think that instead of using this onload approach(above), Simon Willison's addLoadEvent()
function at http://simon.incutio.com/archive/2004/05/26/addLoadEvent would be better, so that
if any user already has something on window load event, the above JS function's call on
window load won't break that!!

this IMHO is a clean solution, however if you don't want to depend on a JS function then the
other solution can be to output the 'window.open' in the 'onclick' event of the link if its set
to be opened in a new window. that would create a lot of useless code(if there are many links)
as 'window.open' would be put on all of them. here's how an example link will look like

~~~~~~~~~
<a href="" >Google</a>
~~~~~~~~~

both of these work in IE6, Opera8.5 & FireFox1.5 for sure, I dunno about other browsers.

------------
Amit Gupta
http://igeek.info/  ||  http://blog.igeek.info/
http://blog.igeek.info/wp-plugins/igsyntax-hiliter
 
_______________________________________________
wp-testers mailing list
[email protected]
http://lists.automattic.com/mailman/listinfo/wp-testers

Reply via email to