473,473 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Detect javascript

wj
Hi all,

Is it possible to detect wether a user has enable javascript is his
browser or not within PHP?

Thanx,
WJ
Jul 17 '05 #1
5 7187
Carved in mystic runes upon the very living rock, the last words of wj of
comp.lang.php make plain:
Is it possible to detect wether a user has enable javascript is his
browser or not within PHP?


No, but it's possible to detect it with Javascript; you can then pass
that information on to PHP. It's a two-step process, though. Your first
page is something like this:

<META HTTP-EQUIV=Refresh CONTENT="1; URL=jstest.php?js=no">

<SCRIPT TYPE="text/javascript">
location = "jstest.php?js=yes";
</SCRIPT>

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Jul 17 '05 #2
wj <wj*******@home.nl> wrote in message news:<co*********@news4.zwoll1.ov.home.nl>...
Hi all,

Is it possible to detect wether a user has enable javascript is his
browser or not within PHP?


<?php
//foo.php
$js = 1;
if (isset($_GET['js']) && $_GET['js']=='0')
$js = 0;
?>
<noscript>
<meta http-equiv="refresh" content="0,URL='foo.php?js=0'" />
</noscript>
<?php
echo $js;
//etc etc
?>

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/
Jul 17 '05 #3
.oO(R. Rajesh Jeba Anbiah)
<noscript>
<meta http-equiv="refresh" content="0,URL='foo.php?js=0'" />
</noscript>


While this might work, it's no valid HTML (noscript is not allowed in
the document's head).

Micha
Jul 17 '05 #4
Yo wj,

Why not simply set a value to a hiddenfield
using a simple javscript-function?

If there is the expected value within
your POST-VARS after submit ...

"wj" <wj*******@home.nl> schrieb im Newsbeitrag
news:co*********@news4.zwoll1.ov.home.nl...
Hi all,

Is it possible to detect wether a user has enable javascript is his
browser or not within PHP?

Thanx,
WJ


berges
Jul 17 '05 #5
Michael Fesser <ne*****@gmx.net> wrote in message news:<26********************************@4ax.com>. ..
.oO(R. Rajesh Jeba Anbiah)
<noscript>
<meta http-equiv="refresh" content="0,URL='foo.php?js=0'" />
</noscript>


While this might work, it's no valid HTML (noscript is not allowed in
the document's head).


Yes, this a good criticism:-) What about this one, which doesn't
rely on meta refresh as browsers could disable it.

<?php
//foo.php
$js = (isset($_GET['js']) && $_GET['js']=='1') ? 1 : 0;
if (!$js)
{
?>
<script>
window.location = "foo.php?js=1";
</script>
<?php
}

echo $js;
//etc etc
?>

Also, if form is allowed to check the JS, it will be much easier
as we can populate any variables on onSubmit event. Also, it could be
much easier to do that in web bug.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ripken95 | last post by:
I connect to the internet through ADSL. I want to write the web page which can detect the connection status with javascript. This detection is like the signal detection in the mobile phone. If the...
1
by: Mat | last post by:
How can I detect when a link has been clicked but the new page is still in the process of loading? The document.location.href property still displays the current location (understandably) not the...
23
by: David McCulloch | last post by:
QUESTION-1: How can I detect if Norton Internet Security is blocking pop-ups? QUESTION-2a: How could I know if a particular JavaScript function has been declared? QUESTION-2b: How could I...
8
by: Brent | last post by:
Does anyone know the best way to detect and track a visitors screen resolution. I know the javascript to detect the users resolution but I am a bit confused on the best way to track and save this....
2
by: Yurij Nykon | last post by:
Hi all. How can I detect the version of Flash-Plugin installed in Internet Explorer? In Netscape i can do this with following java script navigator.plugins.description But it doesn't works...
1
by: DBLWizard | last post by:
Hello, I am trying to find code that will detect if a browser as the Adobe or any PDF plugin. I am writing a subscription only site that needs access to view "pages" in a book that could have...
1
by: madmanahong | last post by:
How to detect a software has been setup safely? First, I think to do it throught registry, I can read from registry if exist a key to detect. but it's not safely...IE popup a tip. ( XP SP2 ) ...
4
by: Uldis Bojars | last post by:
Hi! How can Javascript code detect if a user has been authenticated to see a page, that is, if he has entered a username and password for HTTP authentification to see the current page. Possibly...
4
by: goscottie | last post by:
I used submodal as my popup window. With some tweaks, it working great in my app. However, I can't find a way to detect session timeout in the popup window. The app is a form based...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.