javascript detection with php

General discussions related to php

Moderators: macek, egami, gesf

User avatar
leon
New php-forum User
New php-forum User
Posts: 36
Joined: Sat Aug 03, 2002 11:54 am

javascript detection with php

Postby leon » Mon Oct 28, 2002 6:28 am

Hello ,

I have a problem . I need to write some line of php code to detect if the browser is able to run javascript . If it is not able to run javascript it should stop , exit(); , while if the browser is able to run javascript , the php script should must continue .

Any idea ?
Thanks a lot .

DoppyNL

Postby DoppyNL » Mon Oct 28, 2002 6:34 am

PHP is server side.
Javascript is client side.

So it's not like php "knows" if the client is javascript-capable.

You probably need to make a page wich is displayed first. In this page you got some javascript wich forwards the user to the page wich was specificly made for/with javascript. If the user has no javascript, he will not be forwarded (javascript can't do that, because he hasn't got it :))

Does this make sence? It does to me.
But then again, I don't use ANY javascript myself, only "plain" html, I've yet to find something for wich I need it.

Greetz Daan

User avatar
leon
New php-forum User
New php-forum User
Posts: 36
Joined: Sat Aug 03, 2002 11:54 am

Postby leon » Mon Oct 28, 2002 6:52 am

Hello ,

thanks for reply .

Since I cannot use php header fuction to redirect (it gives me an error , ,headers are already opened , and at this time I cannot fix it ) I need to use a javascript meta refresh like this ;

echo "<meta http-equiv=\"REFRESH\" content=0;URL=anonymous_set.php?check=$check&allowanonftp=$allowanonftp&allowanonftpin=$allowanonftpin>";

If the user stops javascript on his browser , he can get the url with the session id , and could insert custom variables and it's not good for me .

So , before executing the echo above , i need to stop the php code if javascript has been disabled on the browser .... any idea ?

User avatar
leon
New php-forum User
New php-forum User
Posts: 36
Joined: Sat Aug 03, 2002 11:54 am

Postby leon » Mon Oct 28, 2002 7:28 am

I am trying this now ......

<HTML>
<HEAD>
</HEAD>
<BODY>
<SCRIPT language="Javascript">
if (navigator.javaEnabled() == true) {
var javatest = "yes";
document.write(javatest,"<p>")
}
</SCRIPT>
<?php
echo $javatest;
?>
</body>
</HTML>

But echo $javatest; is returning nothing . Any idea ?


Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron