Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

How do I detect Javascript from within PHP

Do different thing if Javascript enabled.



10:00 pm on Mar 8, 2004 (gmt 0)

10+ Year Member

Is there a simple way of detecting whether javascript is enabled on a browser within PHP?

This is what I want it for.
I have to POST form data to a third party site.
After validating it I can only POST data using a form with an autosubmit in Javascript.

I can do it without javascript but this requires an extra button to be clicked. to finally send the data.

I want to do it in the best way if Javascript is enabled and only the other way if it isn't.


3:18 am on Mar 9, 2004 (gmt 0)

10+ Year Member

There is no way since Javascript is client side. You'd have to do something in client side javascript. Ie have javascript add a POST/GET parameter to a form when submited. If the param exists then client has JS if not then they don't.



5:28 pm on Mar 9, 2004 (gmt 0)

10+ Year Member

My solution to the problem I have is very simple once I implemented it. I am posting the answer so that anyone else searching finds it.

This is what the program now does.

1. Fill in the visible form and validate it.
2. Redisplay the page with the invisible form and a message telling the user if they see the message they need to click a button to continue.
3. Submit the invisible form using javascript.

If 3 does not work because of Javascript not working then the user is prompted anyway so both methods are covered.


Featured Threads

Hot Threads This Week

Hot Threads This Month