Web Masters Tips and Tricks.

 

More JavaScript Tips.

Have you ever tried to call a remote JavaScript from within the <body> of your page? I have and I can tell you without reservation that it took me more than a few minutes to finally figure out exactly what was needed to satisfy "ALL" of the respective validators. Calling remote JavaScript's from the <head> section is a piece of cake.
Calling one from the <body> you will need to satisfy a lot of conditions for it to work properly. I built the call by pieces, once I satisfied one validator I found my code was coming up short on another validator. Between the "508" and the "AAA" validator I was beginning to get "slightly" aggravated. It took a while to make it "bulletproof" for all conditions. The first thing you will need to do is to go into your graphics program and create a transparent gif that is 1px by 1px and save it to your image file. You will be using some unfamiliar attributes like <noscript> and <address>. The call seems slightly complex for what it actually does. A working example of what I am referring to will look like this:

<script type="text/JavaScript" src="emailme.js"></script>
<noscript> <div class="fite"><address><img height="1" width="1" alt="" src="/images/noscript.gif" />
</address></div></noscript>

This is a script that I use on all my pages and it is for privacy purposes. It is an e-mail scrambler script that hides my e-mail address from the spiders that crawl the world wide web harvesting e-mail addresses for spam purposes. This has to be used within the <body> so that it will be accessible. The first line is the opening and closing of the remote call of the script. Again I will point to the ease of calling remote scripts as opposed to including them in either the <head> or <body>. of your page. Once you have created a <script> zone in the <body> of your document you now need to create a <noscript> zone to even things out. Inside the <noscript> zone you will inject a couple of attributes. The first thing you will need to add will be a <div>, class or id is optional, use whatever name suits you. This option will be dictated by whether or not you will need to call a script on more than one occasion. You do not need to define this <div> in the <head> section or on your style sheet. The next thing you will to do is to open the address attribute. Inside the address attribute you will call your 1px gif you created earlier. You will then close in the reverse order that you opened all the attributes. What you opened first will now be closed last. This particular code snippet will satisfy all requirements for coding and access including AAA and Section 508. Well now that was pretty easy wasn't it?

Back to top of Page

Opening a new window in XHTML

So you have upgraded to writing XHTML !! Congratulations.
Now you have given up a few of the easy attributes and are now looking to replace some things that are no longer available to you like opening an external target in a new window. Sounds like it's going to be hard but really it's still a piece of cake.
Now you will be looking to implement a lightweight JavaScript.
A working example of the JavaScript I am referring to will look like this:

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

The preceding code will be aptly named external.js and will be located in a java folder the same directory as your html files so the call will be very clear.

The layout on your webpage will go just like this:

<head>
<script src="external.js" type="text/javascript"></script>
</head>

<body>

<a href="http://validator.w3.org/check?uri=referrer" rel="external">Valid XHTML 1.1</a>

</body>

Well, that was easy enough. Here you thought you were going to have to become a Java programmer to solve that little issue, huh?

Stop back once in a while as I will be adding more tips as my time and temperament allow.
[[a]Home ] [[b]Introduction to the Website ] [[c]About the Authors of the Book ] [[d]Foreword ] [[e] Johannes Vogt - The Tennessee Branch ] [[f]Leonard Fite - Isabella Fite ] [[g]Descendents of Leonard & Margaret ]   [[h]Willy Green Fite - James Monroe Fite ] [[i]Thomas Bethel Fite - Flennoy Elgar Fite ] [[j]Clarence Sydney Fite - Effie Gladys Fite ] [[k] Marion Charles Fite - Lucille Fite ] [[l]Arra Burton Fite - Bernice Mabel Fite ] [[m] Frederick Leroy Fite - Elizabeth Fite Thorne ] [[n]LaFayette Doris Fite - Ella Mae Fite ] [[o] Julia Bruton - Paul Leonard Fite ] [[p]The Source ] [[q]Content ] [[r]Explanation of the Coat of Arms ]  [[s]Links Page ] [[t]Privacy / COPPA Statement ] [[u]Accessibility Statement ] [[v] Copyright Statement ] [[w]Updates Page ] [[x]Disclaimer / Terms of Use ] [[y]Site Map ]  [[z]Reflections ] [[1]Web Master Tips-I ] [[2]Web Master Tips-II ] [[3]Web Master Tips-III ] [[4] Web Master Tips-IV ] [[5]Web Master Tips-V ] [[6]Award Pages Index ] [Rated Awards (5.0) I ] [Rated Awards (5.0) II ] [Rated Awards (5.0) III ]  [Rated awards (4.5) I ] [Rated awards (4.5) II ] [Rated awards (4.0) I ] [Rated awards (4.0) II ] [Rated Awards (3.5) I ] [Rated Awards (3.0) I ]  [Rated Awards (3.0) II ] [[7]Independent Awards ] [[8] ICRA Labeled ] [[9]XHTML 1.0 ] [[0]CSS Level 2 ]