Sniff if javascript is enabled 
Author Message
 Sniff if javascript is enabled

Hi

I have a website with some information windows opened with the window.open()
Javascript command. To make all information accessible (also for search
engines) I would like to check the user agent if Javascript is enabled, so I
could provide a normal href link for non javascript user agents. Is there a
possibility with PHP to sniff the presence of Javascript?

Thanks for a hint.

--
Markus



Sun, 31 Jul 2005 17:39:25 GMT  
 Sniff if javascript is enabled

Quote:

> Is there a possibility with PHP to sniff the presence of
> Javascript?

Obviously, the good old <NOSCRIPT> can help you out. Like

  <script language=".."><!--
    document.write('JS Enabled! <a href="...&js=yes">Click me</a>');
  --></script>
  <noscript>
    No JS support, or disabled. <a href="...&js=no">Click me</a>
  </noscript>

Of course, you can use the above to create a META REFRESH thing in the
<HEAD> part, to achieve fetching the desired page without clicking.

Also some browsers might send some extended capabilities to the web server,
but I doubt you can rely on that (when I use http://php.net/phpinfo from my
Mozilla I do not see any JavaScript details so I doubt there's something
that the server is keeping PHP from seeing here).

Palahala



Sun, 31 Jul 2005 17:54:54 GMT  
 Sniff if javascript is enabled
Thank you, this is a good idea. I thought of something similar, just putting
a self.location.href="page_with_javascript" in the header, but I would
prefer to have only one file, something like

<?
if(ua.javascript is enabled) $js=true;
?>

and then write the link like

<a href="<? if(js) echo 'javascript:window.open...'; else echo 'file.php';
?>"

I will check out the link you provided at php.net; I was looking for this
info at php.net but did not find out what exactly to look for, thanks.

--
Markus



Quote:

> > Is there a possibility with PHP to sniff the presence of
> > Javascript?

> Obviously, the good old <NOSCRIPT> can help you out. Like

>   <script language=".."><!--
>     document.write('JS Enabled! <a href="...&js=yes">Click me</a>');
>   --></script>
>   <noscript>
>     No JS support, or disabled. <a href="...&js=no">Click me</a>
>   </noscript>

> Of course, you can use the above to create a META REFRESH thing in the
> <HEAD> part, to achieve fetching the desired page without clicking.

> Also some browsers might send some extended capabilities to the web
server,
> but I doubt you can rely on that (when I use http://php.net/phpinfo from
my
> Mozilla I do not see any JavaScript details so I doubt there's something
> that the server is keeping PHP from seeing here).

> Palahala



Sun, 31 Jul 2005 18:18:26 GMT  
 Sniff if javascript is enabled
This is genious! Thank you.

--
Markus



Quote:
> On Wed, 12 Feb 2003 11:18:26 +0100, "Markus Ernst"

> Snipped Newsgroups I don't take..

> ><?
> >if(ua.javascript is enabled) $js=true;
> >?>

> >and then write the link like

> ><a href="<? if(js) echo 'javascript:window.open...'; else echo
'file.php';
> >?>"

> The correct way to do all javascript links IMHO is to do the following

> Make a normal link.
> Add a javascript onClick with a return false

> Then if the user has javascript the popup will work and if they dont
> the normal link will work.. No need for testing

> eg: (Untested)

> <a href="this.php" target="_blank" onClick="popup(\"this.php\") return
> false">

> popup() being a function that opens a popup window.



Sun, 31 Jul 2005 19:48:46 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. IE5, JavaScript & VRML-enable detection

2. IE6 +VRML + javascript in VRML trouble (was: problem using javascript window.open in VRML)

3. I am not deaf, but am I mute?

4. Eiffel parser for SNiFF+

5. Sniffing

6. sniff and eiffel

7. Sniff

8. YASD: *sniff* almost 2nd victory

9. assembler and sniff+ ???

10. sniffing btw my web browser and a server

11. SNiFF+ for Linux

12. SNiFF+ and Fortran

 

 
Powered by phpBB® Forum Software