Using [ICODE]<script language="JavaScript" src="javascript.js" type="text/javascript"/>[/ICODE] is not valid (as per the W3C) for 2 reasons. The first being that the script tag is a content element and must use a [ICODE]</script> [/ICODE] to close the elements envelope. The second, if the script tag was a leaf (contentless) element, there must contain a space before the [ICODE] /> [/ICODE]. Using [ICODE]language="JavaScript"[/ICODE] has been deprecated.

The only exception to this is when using XHTML, and although using the script tag as a leaf element will parse correctly in most modern browsers, it will cause the page to break in older browsers. This lack of backward compatibility is the primary reason the W3C will ONLY validate the script tag as a leaf element when used in XHTML.

To prove this point, I have provided a [URL="

I have noticed that there is no longer a help page in the FAQ on how to use [B][TAGS][/B] in the editor. Can we please get a help button? Maybe after the check spelling button?

[U]It would be helpful if the help included best-practices and examples[/U] :)

The only way to access that object without [] would be to give it an id/name or path to it using a node reference such as [icode]...nextSibling[/icode] from an object you are able to reference.

I would suggest working this problem from another angel and find a way to access the page through another medium. Even if you do solve the immediate, JavaScript relies heavily on arrayed objects and you will likely end up with the same problem all over again.

Best of luck :)

Hello,

First, I want to say that you can type [ and ] on the iPhone though I did see that people where having problems typing brackets in some terminal applications.

Second, square brackets are a core component in JavaScript, despite the fact that I was able to create a function for you, you will run into many problems not being able to use them.

Here is the script:
[code] <script type="text/javascript"><!--//

// set your array
var a = new Array("dog","cat","bird")

// prototype function to access the array
Array.prototype.getArrayNum=function(num){var val=this.toString()+",";for(var i=0;i<num;i++){val=val.substring(val.indexOf(",")+1)}return val.substring(0,val.indexOf(","))}

// just type the number of the array element you want
alert(a.getArrayNum(3))

//--></script>[/code]

Enjoy! :)

Thank you for your comments they are much appreciated.

With respect to your viewpoint with treating the page as a scroll, I agree that this is how most development is done. I have been designing web pages since the late 90’s and have watched the evolution of browsers. Browsers have slowly become a portal of how we interact in our society. This evolution has only been possible because of standards that have been implemented to allow for greater control of its environment. In my professional observation, the limitations often occur only when the standards are not followed.

As the use of browsers have advanced beyond simple webpages and more toward web based applications, a greater level of precision is required to deliver dynamic content. If we all had succumbed to the idea of “oh… it was never designed for that” we would never of had the advent of AJAX, .NET, and many other recent web based technologies. As I have demonstrated in my post, most browsers adhere to some level of the W3C standards these days, though as my post clearly shows, some browsers do have shortcomings.

Contrary to your statement, I have a library of functions that do exactly what you state browsers weren’t designed to do, and I have been doing it for many years. My efforts recently have migrated toward updating these functions to be more cross-browser/cross-doctype compactable by taking advantage of XHTML. I have nearly completed the new set of functions and as demonstrated most all ...

Hello,

First let me start with the fact that JavaScript is a [I]human[/I] language designed to give instructions to an application. As such, it should be used in a manner that is easy for [I]people[/I] to read. Proper formatting is critical to allowing [I]people[/I] to understand the instructions so that errors are not made that would cause the application to fail the execution of the script. That said, I found that in [icode]function checkform()[/icode] you placed too many end brackets and is the most logical cause of the script failing.

I have taken the time to cleanup your code. However, without the html part of your page it is impossible to do any further troubleshooting. I would strongly suggest using an editor that is designed to help [I]people[/I] work with code like [URL="

That is a good way to handle it if you are wanting to insert an [icode]<img />[/icode] tag. A faster rendering method would be to place the image tag directly next to the input field like so:
[code]<input id="passField" name="passField" type="text" /><img id="passFieldImg" src="blankimg.gif" />[/code]

You can then change the image in your validation function using:
[code]if( /PASS CONDITION/ ){
document.getElementById('passFieldImg').src="pass.gif"
}
else{
document.getElementById('passFieldImg').src="fail.gif"
}[/code]

Hello,

OK... at first glance, the problem is that the calculate function is only working under 2 conditions, the first [icode]document.layers[/icode] for old Netscape, and the second [icode]document.all[/icode] for Internet Explorer.

I’m not seeing anything in the [icode]document.all[/icode] section that appears to be IE specific.

Try changeing the [icode] if (document.all){[/icode] to [icode] else{[/icode].

I this fails to work let me know and I will take a closer look at it.

Hi All,
This is the parent issue that led to the post [B]Need help with getDOCTYPE() function[/B] ([url]http://www.daniweb.com/forums/thread196837.html[/url])

[B]USING THE BODY METHOD:[/B] The following code will properly get the viewable window area if no DOCTYPE is specified.
[icode]document.getElementsByTagName("body")[0].clientWidth//Height[/icode] [B]OR[/B] [icode]document.body.clientWidth//Height[/icode]

If DOCTYPE is XHTML ANY* the above code reports only the defined page area as if it was a wraper**.

[B]USING THE HTML METHOD:[/B] The following code will properly get the viewable window area when DOCTYPE XHTML ANY* is used.
[icode]document.getElementsByTagName("html")[0].clientWidth//Height [/icode] [B]OR[/B] [icode]document.documentElement.clientWidth//Height [/icode]

If no DOCTYPE is used the above code reports only the defined page area as if it was a wrapper**, EXCEPT IE6+ (not tested in older browsers) reports 0.

So the problem here is how to create a cross-doctype compatible function for getting the width & height of the window/frame. I have played with several methods but each produced problems. The best solution I can think of is to detect the doctype by using the following code:

FireFox3, Safari and Chrome*** work according to the W3C standard [icode]document.doctype[/icode] using [icode].publicId[/icode] & [icode].systemId[/icode], but this causes IE to get a hard error. IE will however allow reference to the DOCTYPE through node objects. Both [icode]document.body.parentNode.parentNode.firstChild.nodeValue[/icode] and [icode]document.getElementsByTagName("!")[0].nodeValue[/icode] work in IE but not other browsers. So I came up with a function to tackle this issue:

[code=javascript]function getDOCTYPE(){
var pid,sid,val,lng,ver,typ;
try{
pid=String(document.doctype.publicId);
sid=String(document.doctype.systemId);
}
catch(err){
val=String(document.body.parentNode.parentNode.firstChild.nodeValue)
pid=val.replace(/^[^\"]\"([^\"]+)\"./,"$1");
sid=((/http/).test(val))?val.replace(/^.\"\s\"(http.)/,"$1"):null
}

lng=((/xhtml/i).test(pid+sid))?"XHTML":"HTML";
typ=((/strict/i).test(pid+sid))?"Strict":((/trans|loose/i).test(pid+sid))?"Transitional":((/frame/i).test(pid+sid))?"Frameset":((/basic/i).test(pid+sid))?"Basic":((/mobile/i).test(pid+sid))?"Mobile":null;
ver=((/html\s\d+.?\d/i).test(pid))?pid.replace(/^.html\s(\d+.?\d)\D/i,"$1"):null;

return {publicId:pid,systemId:sid,language:lng,type:typ,version:ver,set:lng+" "+typ+" "+ver}
}[/code]

As the page must be fully rendered before the ...

in javascript it would be done this way if someone would like to translate it to php

[code]
var a="bob";
var b="joe";

a=[a,b];b=a[0];a=a[1];
[/code]

enjoy! :)

Hello,

wasn't sure if you where aware that [icode]filters.blendTrans[/icode] only works in IE...

the better way to handle this for cross-browser support is by using [icode]DOM .opacity[/icode]

If I can find some time over the next few days i will put a sample together for you.

By the way,
Chrome only works when using

[code=html]
<meta name="content-type" content="application/xhtml+xml; charset=iso-8859-1" />
[/code]

To simplify the issue:
alert(document.body.parentNode.parentNode.firstChild.nodeValue) //does not seem to properly refrence the doctype node
// I have tried many other node paths and have had no luck accessing the doctype :(
alert(document.getElementsByTagName("!")[0].nodeValue) // I just stumbled across this trying different methods.

alert(document.doctype.publicId) //seems to be unsupported even though all references I have state that it is supported in XML and XHTML (for Opera)

Hi All,

Without getting into too much history on the why, I came into a situation where I needed to create a function to get various properties of !DOCTYPE so that other functions could adjust to work properly with certain DOCTYPEs (Strict, Transitional, etc.). I have tested the function in the following Windows browsers IE6+ FF3+ Chrome2+ and Safari3+ Opera9+. The only one that I can’t get working is Opera (testing with 9.64). I’m hoping that someone out that has a solution! Here is the code:

[code]
function getDOCTYPE(loc){
loc=locEval(loc)||self; // locEval is a function i use to qualify window/frame paths
var pid,sid,val,lng,ver,typ;

try{ // this is the node model that should be supported by all browsers. IE gets a hard error with it though.
pid=String(loc.document.doctype.publicId);
sid=String(loc.document.doctype.systemId);
}
catch(err){
val=String(loc.document.body.parentNode.parentNode.firstChild.nodeValue) // seems to only work in IE
//val=document.getElementsByTagName("!")[0].nodeValue // works in IE as well

pid=val.replace(/^[^\"]*\"([^\"]+)\".*/,"$1");
sid=((/http/).test(val))?val.replace(/^.*\"\s\"(http.*)/,"$1"):null

}

lng=((/xhtml/i).test(pid+sid))?"XHTML":"HTML";
typ=((/strict/i).test(pid+sid))?"Strict": ((/trans|loose/i).test(pid+sid))?"Transitional": ((/frame/i).test(pid+sid))?"Frameset": ((/basic/i).test(pid+sid))?"Basic": ((/mobile/i).test(pid+sid))?"Mobile": null;
ver=((/html\s\d+.?\d/i).test(pid))?pid.replace(/^.html\s(\d+.?\d)\D/i,"$1"):null;

return {publicId:pid,systemId:sid,language:lng,type:typ,version:ver,dtd:lng+" "+typ+" "+ver}
}

//...

alert(getDOCTYPE().dtd)

[/code]

Any help would be greatly appreciated! :)