[thelist] XHTML 1.0 Strict -no target attribute allowed?
Courtenay
court3nay at gmail.com
Sun Oct 24 00:28:56 CDT 2004
Here's an interesting modification I just thought of.. I have a pet
peeve - I hate it when links open in a new window. In fact, if I want
them to open like that, I middle-click in firefox to open in a new
tab, so _blank is redundant, and an annoyance, (yes I know you can get
an extension for this, but it messes with download and javascript
debugger windows).
I don't want to start a default-checkbox war here, but here's a little
workaround, if anyone's interested (or can fix it up a bit),
put a checkbox at the top (or bottom) of the page that says
"open new links in new window" thus:
<input type='checkbox' id='opennew' onchange='OutLinks();'
checked='checked'>Open links in new window
then in your code
function OutLinks() {
var wlhref = window.location.href;
var dlinks = document.links;
for (var i=0; i<(dlinks.length); i++)
if ((dlinks[i].href.indexOf(wlhref)==-1))
if (document.getElementById('opennew').checked)
dlinks[i].target = '_blank';
else
dlinks[i].target = '';
}
}
You could probably adjust the code to check for your domain (regexp
for a generic function i guess) and open 'true' external links as
well.......
On Sat, 23 Oct 2004 22:48:41 -0500, Earl Cooley <shiva at io.com> wrote:
> I use some Javascript that goes through the page and adds a
> _blank Target to every external link it finds:
>
> function outLinks(){
> var wlhref = window.location.href;
> var dlinks = document.links;
> for (var i=0; i<(dlinks.length); i++)
> if ((dlinks[i].href.indexOf(wlhref)==-1))
> dlinks[i].target = '_blank';
> }
>
> window.onload = function() {
> outLinks();
> }
More information about the thelist
mailing list