Loading...


bookmark - Opening A Window (xhtml Valid Way) opening a window while being XHTML valid

Opening A Window (xhtml Valid Way) - opening a window while being XHTML valid

 
 Discussion by overture with 7 Replies.
 Last Update: May 9, 2005, 2:16 pm
 
bookmark - Opening A Window (xhtml Valid Way) opening a window while being XHTML valid  
Quickly Post to Opening A Window (xhtml Valid Way) opening a window while being XHTML valid w/o signup Share Info about Opening A Window (xhtml Valid Way) opening a window while being XHTML valid using Facebook, Twitter etc. email your friend about Opening A Window (xhtml Valid Way) opening a window while being XHTML valid Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

This is going to be an extremely simple tutorial for you all. I know many people still don't understand XHTML in the respect of "why use it", but this tutorial is not to explain to you why, i believe mastercomputers explained it all in another topic. This topic is to tell you how to open another window while being XHTML 1.0, 1.1 valid.

I will be using Javascript so you can either put the code in an external file and link to it (remember to add the '/' before the '>' :P ).

This is the simple Javascript function we will be using:

CODE

function launchit(url) {
[tab][/tab]window.open(url);
}


This function when called upon will create and open a window which will take you to the website which has been given.

The above code has a variable within it called 'url', this is so that it knows that something is going to be used in order for the function to work correctly, in this case a website address.

This is the code to use it correctly:

CODE

<a href="http://overture.uni.cc" onclick="launchit('http://overture.uni.cc'); return false;">Some Link</a>


As you can see the function is called upon using the onclick event within the anchor tag. I hear you say "what does the 'return false' do". This basically stops the focused window (the window which the link is on) to not go to that website as we want it to open in another window (that is the whole point of this tutorial).

The normal way to do this would be to use this code:

CODE

target="_blank"

This would open the window getting the url from within the href="".

This however is not valid XHTML and will return and error when it is checked. This is because the 'target' attribute is not supported in XHTML 1.0 or 1.1. I do believe it is in XHTML TRANSITIONAL (could someone verify that for me).

Well that is it. I believe this all works correctly. If not tell me the problem and i will try and correct yours or my mistake.

overture.

   Mon Feb 14, 2005    Reply         

So let me confirm this: there is no other way to open a new window without using Javascript under XHTML1.0Strict??

   Thu Apr 7, 2005    Reply         

as far as i know... no. although i haven't searched the web for other ways if there are any. javascript would still be needed to be used as this is the only way to open another window as the "target="_blank"" has been removed. it is an easy way none the less. :P

   Thu Apr 7, 2005    Reply         


>_< I'm taking the easy way out, writing (off-site) next to all the links I used to make pop into new windows, and writing a line in my introduction that says that all links marked with (off-site) lead out of the site and visitors are advised to open them in new windows.

Does away with the whole target and javascript thing. Sometimes the easiest ways are the least thought-off...

By the way, just asking, would this particular javascript still allow people to open the window in a new tab or other similar shortcuts? As in would it override all other ways of opening the site?







   Thu Apr 7, 2005    Reply         

yeah. you can still open in a new tab by doing the usual process and you can also use shift + click to open in a new window also. the Javascript code does not remove any other way of doing opening the website/page. it is just a replacement method for people who want to be Strict in their coding.

   Sun Apr 10, 2005    Reply         

There is a way open links in new window without Javascript and using valid XHTML.

You can add more methods to XHTML. You can either load a DTD supporting target or add it to it inside the <!DOCTYPE>

What to add is:

CODE

[ <!ATTLIST a target CDATA #IMPLIED> ]



Notice that most browsers (including geckos and IE) show "]>" at the top of the page. This sucks but you can hide it using CSS change it to background-color. Also I believe it will disappear from Geckos at least. Opera does not show it.

   Wed May 4, 2005    Reply         


Sorry, Hercco, not really understanding what you wrote. What does that tag do??

   Thu May 5, 2005    Reply         

Herrco i tried this before and it never worked. Like you said it shows the "]>" at the top of the page which if you have something which needs to be positioned right at the top then it will be moved out of place. it did not even open the links in a new window. i had this answer in an old forum i was at before i came to this one and still it didn't work. i still think the little bit of Javascript is best and most efficient way as it works absolutely perfectly :(

   Mon May 9, 2005    Reply         

Quickly Post to Opening A Window (xhtml Valid Way) opening a window while being XHTML valid w/o signup Share Info about Opening A Window (xhtml Valid Way) opening a window while being XHTML valid using Facebook, Twitter etc. email your friend about Opening A Window (xhtml Valid Way) opening a window while being XHTML valid Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

Similar Topics:

Php/xhtml Pages

As you know, if you use the XML encoding tag, XHTML Doctype and the XML Namespace attribute in the html tag on a .php document, it won't render properly and will infact display errors. A solution to this problem is to use the require function of the PHP system. ( ...more

   28-Oct-2006    Reply         

Problem With Xhtml Validation

Hi, i have a problem when i try to validate a php page that includes a litlle form and use sessions as a strict xhtml 1.1 page with the W3C XHTML VALIDATOR, the problem consists that everytime i send it to the validator it creates a hidden input with the PHP PHPSESSID in the form and also adds to th ...more

   02-Feb-2007    Reply         

Xhtml Validation With Php In Cgi Mo...

Hi, Recently the host server of one of my clients change its PHP installation from the Apache mode to the CGI mode so because of this change i got some problems. For example, whatever page i view it shows these warnings at the top of the page: Warning: session_start() [function. ...more

   01-Apr-2007    Reply         

Converting HTML over to XHTML Crossing over to the darkside   Converting HTML over to XHTML Crossing over to the darkside (13) (7) HTML 101 - Web Design For Beginners Absolute Basic HTML Writing  HTML 101 - Web Design For Beginners Absolute Basic HTML Writing