Posts filed under 'XHTML'

XHTML: Open a link in a new window - V2

Marc-Antoine Ross February 3rd, 2007 Add comment

I used my friend Mario’s great post on how-to open a link in a new window to create a script that will open any external link in a new window without the need to add a CSS class to it. This is very useful when you want to change the behavior on a blog that already has a lot of posts.

<script type=”text/javascript” language=”JavaScript”>
    function externalLinks() {
        if (!document.getElementsByTagName) {
            return;
        }
        var anchors = document.getElementsByTagName(”a”);
        var sDom    = document.domain;
        for (var i=0; i<anchors.length; i++) {
            var anchor = anchors[i];
            if (anchor.getAttribute(”href”)) {
                iPosition = anchor.href.indexOf(sDom);
                if (iPosition == -1 ||
                    iPosition > sDom.length) {
                    anchor.target = “_blank”;
                }
            }
        }
    }
    window.onload = externalLinks;
</script>

The Multipage Validator as an official Google button

Marc-Antoine Ross April 25th, 2006 Add comment

Mario and I are very happy to announce that the Multipage Validator button has been added to the Google Toolbar button gallery. This button works with our Multipage Validator which is a very powerful tool to validate your website’s HTML or xHTML code.

XHTML bases

Mario Laflamme March 15th, 2006 Add comment

Here is a list of different valid XHTML bases which can be used. The first one is the one that I use most of the time, but the others can be useful in certain cases.

Please note that the file “/scripts/links.js” used in the XHTML bases contains the function which allows to open links in a new window as explains it the article “XHTML: Open a link in a new window“.

XHTML 1.0 Strict with ISO-8859-1 encoding
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en”>
    <head>
        <title></title>
        <meta http-equiv=”content-type”
         content=”text/html; charset=iso-8859-1″ />
        <script type=”text/javascript”
         src=”/scripts/links.js”> </script>
        <link rel=”stylesheet” href=”/styles/styles.css” />
    </head>
    <body>
        
    </body>
</html>
XHTML 1.0 Transitional with ISO-8859-1 encoding
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en”>
    <head>
        <title></title>
        <meta http-equiv=”content-type”
         content=”text/html; charset=iso-8859-1″ />
        <script type=”text/javascript”
         src=”/scripts/links.js”> </script>
        <link rel=”stylesheet” href=”/styles/styles.css” />
    </head>
    <body>
        
    </body>
</html>
XHTML 1.0 Frameset with ISO-8859-1 encoding
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en”>
    <head>
        <title></title>
        <meta http-equiv=”content-type”
         content=”text/html; charset=iso-8859-1″ />
    </head>
    <frameset rows=”100,*”>
        <frame src=”header.html” />
        <frame src=”content.html” />
        <noframes>
            <body>
                <p>Warning! Your navigator doesn’t
                support frames.</p>
            </body>
        </noframes>
    </frameset>
</html>

XHTML: Open a link in a new window

Mario Laflamme March 9th, 2006 1 comment

Sure, you can to use the tag target=”_blank” to open a link in a new window with XHTML, but this tag is not valid. A simple and effective alternative is to insert the following JavaScript function in your pages and to add the tag rel=”external” to the appropriate links.

<script type=”text/javascript” language=”JavaScript”>
    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.target = “_blank”;
            }
        }
    }
    window.onload = externalLinks;
</script>

Schedule

July 2008
M T W T F S S
« May    
 123456
78910111213
14151617181920
21222324252627
28293031