OutFront Forums
     Home    Register     Search      Help      Login    

Recent Posts
Todays Posts
Most Active posts
Posts since last visit
My Recent Posts
Mark posts read

Sponsors
Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax
Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.
Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

 

Alternatives to target=_blank for xhtml strict

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> Microsoft FrontPage Help >> Alternatives to target=_blank for xhtml strict
Page: [1]
 
Professional Website Management
spinningjennie

 

Posts: 326
Joined: 2/20/2002
From:
Status: offline

 
Alternatives to target=_blank for xhtml strict - 7/3/2006 6:29:29   
What is the best alternative for target=_blank when using xhtml 1.0 strict? The w3c validator rejects it. I want my external links to open in a new window, so that if a viewer closes the window, they get back to my website.

I've tried the following:

1. Used javascript in this page to link to this external.js file which contains the following code but I can't get it to work:

function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors;
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
}

2. I've also added text beside the links in this alternative page to get the viewer to use Shift + Click to open the links. It does work but I think it looks a bit unusual.

3. As an alternative I might change my document type from Strict HTML to Transitional HTML so that target=_blank is accepted. I haven't tried this yet. I would have to compromise on strict xhtml, so I was reluctant.

Any advice much appreciated!

spinningjennie

Reflect

 

Posts: 4742
From: USA
Status: offline

 
RE: Alternatives to target=_blank for xhtml strict - 7/3/2006 8:22:03   
I feel you.

This is the best I could do using strict myself. It is also JS, which IMHO, is a waste or code bloat. I just want to validate to strict so I need to add another ten lines of code :).

http://weblogtoolscollection.com/archives/2004/01/02/targetblank-xhtml-10-strict-conversion/

Anyone have a better solution?

Take care,

Brian

_____________________________


(in reply to spinningjennie)
Tailslide

 

Posts: 6708
Joined: 5/10/2005
From: Out here on the raggedy edge
Status: offline

 
RE: Alternatives to target=_blank for xhtml strict - 7/3/2006 8:38:39   
If you're sure you want to use a pop-up then use this:

<a href="some.html" onclick="return ! window.open(this.href);"> some place</a>


That way, if people have JS off then it just opens within the same window. Do make sure you warn people that it opens in a new window though!

_____________________________

Little Blue Plane Web Design | Land Rover project

:)

(in reply to Reflect)
spinningjennie

 

Posts: 326
Joined: 2/20/2002
From:
Status: offline

 
RE: Alternatives to target=_blank for xhtml strict - 7/3/2006 22:10:45   
Thanks so much Reflect and Tailslide!

1. Tailslide's suggestion works very neatly with little code.

2. Reflect, the link you provided gave the SitePoint link where I got the javascript code in my 1st post. I've now got that external.js file to work. I just needed to add the last line of code:

window.onload = externalLinks;

A big thanks!

spinningjennie

(in reply to Tailslide)
Page:   [1]

All Forums >> Web Development >> Microsoft FrontPage Help >> Alternatives to target=_blank for xhtml strict
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts