open an link in a new (_blank) window in XHTML 1.1

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

open an link in a new (_blank) window in XHTML 1.1

Post by vigge89 »

I decided to code my new site in XHTML 1.1, but i've come to an problem;
XHTML 1.1 doesn't allow the target="" attribute in anchors (<a></a>).
I want to load a link in a new window, but how can i do this if targets are disabled? is there some else attribute which does this? using javascript is maybe possible, but it's too simple too use JS :?

Thanks in advance.
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

to open a windows in javascript it's simply

Code: Select all

function openren() &#123;
	window.open("path_to_the_file.php", "", "width=500,height=500,toolbars=no,menubar=no,statusbar=no,resizable=no,scrollbars=no,history=no");
&#125;
If you want everything (menu bar history adress bar scrollbar, well just put yes)
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

yeah, i know that can be done, but I wondered how you are supposed to open new windows with, when target is disabled, there's gotta be some way else then using javascript, or have w3 gone mad? :? :wink:
zenabi
Forum Commoner
Posts: 84
Joined: Mon Sep 08, 2003 5:26 am
Location: UK

Post by zenabi »

This page will help you:

http://www.sitepoint.com/article/standa ... iant-world

Unfortunately it does require some JavaScript and I came across a problem with it not working in older browsers.
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

Err didn't know that , interesting.
But, write ALL THAT to get a _blank applied, when you could simply just put a small js script.
...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that doesn't look like much to have written in...
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

nope, it's a good solution, hopefully it'll work for most browsers :)
i came to a problem when changing the DOCTYPE too XHTML 1.1, my menu got misplaced somehow (after changing back to XHTML 1.0, it worked again :? ), so i'll probably keep the XHTML 1.0 doctype, therefore, i wont need this right now.

thanks for the answers everyone :D
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

feyd wrote:that doesn't look like much to have written in...
Agreed but. err it's still more stuff to write.
And I just didn't see the reason not to use a window.open

Anyways that was just my opinion glad you got the answer you were looking for 8)
Post Reply