Click to See Complete Forum and Search --> : Checking if JS is enabled with get_brower()


itbeings
09-18-2006, 08:47 PM
I need the code I can use to chek if JS is enabled and verify or check verion. With get_browser, I could get the Array [ ] result with printf(). But How will I call out the values to check if JS is enable. Pls help.

NogDog
09-18-2006, 09:05 PM
There is no way for your PHP script to directly know if the client has JavaScript enabled. A function such as get_browser() might tell you if the detected client supports JavaScript, but not whether it has been enabled or disabled by the user. And of course, any such browser information can potentially be blocked or spoofed by the user.

If you're working with some sort of form sequence, you can write JavaScript on the first page of the sequence to set a hidden form element's value to indicate the JS is enabled, then grab that info in the page called by that form's action. (Note, though, that even that could be spoofed by a malicious user.)

JPnyc
09-18-2006, 10:07 PM
One way to do this is to have the pHP serve a non-JS version of the page, with a JS redirect to the JS version of the page. If there's no JS, then obviously the redirect does nothing and they get a usable page. If it's enabled then the user is redirected to the JS version of the page.

itbeings
09-19-2006, 02:35 AM
What I want to do mainly is to setup options. If the user is not allowing script then move to a site version with no script and if script is allowed move to the one with script. Pls help with code expression.

bokeh
09-19-2006, 02:41 AM
If you write your Javascript/website properly it should work whether or not the client has Javascript enabled without the need to divert anyone to another page.

Phill Pafford
09-19-2006, 07:16 AM
Here is a way I found to see if javascript is enabled


<html>
<head>
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
window.location="http://www.yahoo.com/";
</script>

</head>
<body>
<table border="0" align="center" width="90%">

<tr>
<td>&nbsp</td>
<td align="center"><font color="red" size="5"><strong>Javascript is not enabled on your browser</strong></font></td>
<td>&nbsp</td>
</tr>

</table>
</body>
</html>



If JavaScript is enabled, they will be redirected, if its disabled they will see the message, "Javascript is not enabled on your browser".

Once they enable JavaScript they will automatically be redirected, no refresh necessary.

bokeh
09-19-2006, 07:25 AM
Here is a way I found to see if javascript is enabled

If JavaScript is enabled, they will be redirected, if its disabled they will see the message, "Javascript is not enabled on your browser".

Once they enable JavaScript they will automatically be redirected, no refresh necessary.Isn't this one of the ways to get your site banned from Google?

Phill Pafford
09-19-2006, 07:42 AM
Really??? why would Google ban the site if you used this? Im am at a loss, please explain more.

If they do Im sorry for posting this method, I never intended to post code that would hinder/ban someones website. :(

Charles
09-19-2006, 07:47 AM
Because Google will never get to your content. And neither will we users who do not use JavaScript so that's more of a feature than a bug.

Phill Pafford
09-19-2006, 08:00 AM
This is just a question for my own personal insight.

How do sites like Gmail run without javascript? or do all users have to allow some javascript to be enabled to use certain features from some sites?

Myself, I do not run javascript for every site only select site which I allow, but if I dont allow them most do offer a message of some sort that states I need javascript enabled to use there site.

Thanks

bokeh
09-19-2006, 09:18 AM
Really??? why would Google ban the site if you used this? Im am at a loss, please explain more.Google will ban any site that returns radically different content to a search engine than a browser. Redirecting based on user agent settings is one such situation. How do sites like Gmail run without javascript?I know this doesn't directly answer your question but poorly designed websites can create unnecessary barriers for people with disabilities, just as poorly designed buildings prevent some from entering. Designers may not realize how simple features built into a web page will assist someone who, for instance, cannot see a computer monitor or use a mouse.

In the US the ADA contains legislation that all commercial websites must follow. Several well known US websites owners are currently in court over such issues.

In the UK there is a sweeping obligation on all websites offered to the public that they must be accessible and usable by disabled people.

Other countries are following the UK's approach. On 25th August 2006, the United Nations published an agreed text of a draft International Convention on the Rights of Persons with Disabilities. It addresses web accessibility among its many provisions.

Amongst the draft Convention's provisions is a clause which orders signatory states to "take appropriate measures to ensure to persons with disabilities access, on an equal basis with others, to … information, communications and other services, including electronic services".

Obviously any site that singles out clients based on user agent and scripting languages is contravening these conventions and sooner or later if they don't sort their act out there will be a queue of people waiting to sue them.

Phill Pafford
09-19-2006, 10:06 AM
WOW!! Thanks for the insite, this totally opened my eyes. I will research this some more to incorporate this into my coding style.

But then I have another question (Sorry I know this is someone elses post) but I guess its the same question. How do I check and ask the user to enable javascript so I can run the validations needed for proper use of my site or any site for that matter?

bokeh
09-19-2006, 10:25 AM
How do I check and ask the user to enable javascript so I can run the validations needed for proper use of my site or any site for that matter?Validations done clientside are an unnecessary luxury and should always be redone done serverside. If your site relies solely on clientside validations it is insecure.

Phill Pafford
09-19-2006, 04:10 PM
ok I will implement client side validation as well, but here is a site that detects if javascript is disabled, how are they doing this?

http://www.vistaprint.com/vp/errjscript.aspx

sry Im asking so many questions but I have a site that does this, it is not really open to the public but relies heavely on javascript validation. I had some php validation as well but I thought it to be redundant, but I guess not.

thanks again for all the insight on this subject