A forewarning here, I’m a complete JS noob, I’ve done websites for a while but never handled JS aside from snippets and the like. I know HTML, CSS, XML, SQL, PHP, Perl and a little ASP. I also code software in Delphi and C#, to give you some background in to what I do know, JS certainly not being one of them. I’ve been going through tutorials and eBooks etc. for now and learnt the basic syntax but I have gone no further, no complex scripts wrote – only simple things.
My question is a two parter. A.) Is it possible to disable a form, or simply the elements of a form, based on the response from an if statement rather than onclick etc. B.) Is the method I’m using in the code posted below efficient for selecting browser?
Here’s the code, I want to test see if the browser is Firefox which is best for my site, if not then if it is Internet Explorer and at this point to disable the form and tell them to download Firefox to gain access or an else to catch all other situations to simply recommend Firefox but nothing more.
[CODE]<script type=”text/javascript”>
if(navigator.appVersion == “5.0 (Windows)”) {
} else if(navigator.appVersion == “5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)”) {
document.write(“I refuse to allow anyone using Internet explorer to access this website. Please either visit on a seperate browser, I recommend Mozilla Firefox, or simply leave the website.”);
disable(true)
} else {
document.write(“Mozilla Firefox is the most appropriate browser for this website, please download it before continuing to get the full experience.”);
}
</script>
Thanks in advance for any help guys!