Re: Javascript detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2007-01-01 at 16:14 -0500, tedd wrote:
> Hi gang:
> 
> I've asked this request on a couple of other list, but considering 
> that I've done this with a mixture of php and javascript, perhaps 
> some of you might check this out for me.
> 
> Try this:
> 
> http://sperling.com/js_detect
> 
> Does this technique work to detect your browser's javascript setting?
> 
> Also, if you change your browser's javascript setting, please restart 
> your browser before rechecking the link.
> 
> If this works well enough, I'll post the code.

It doesn't seem to be working for anyone (me neither btw)... why not use
a simpler approach? Here's an example that doesn't use a redirect. Due
to using the onload mechanism we can be certain that the order of the
updates to the session occurs in expected order (if javascript is
enabled) which is as we want.

Feel free to use as you please...

<html>
    <head>
        <script type="text/javascript" language="javascript">
        <!-- //

        function onLoadStuff()
        {
            if( !document.getElementById )
            {
                //
                // Screwit... yucky old browser!
                //

                return;
            }

            var ePhoneHome =
                document.getElementById( 'phoneHomeForJs' );

            if( ePhoneHome )
            {
                ePhoneHome.innerHTML =
                    '<img src="/phoneHome.php?javascript=1" />';
            }

            var eStatus = document.getElementById( 'javascriptStatus' );

            if( eStatus )
            {
                eStatus.innerHTML =
                    'Javascript detected... WOOOOHOOOOOO!';
            }
        }

        // -->  
        </script>
    </head>

    <body onload="onLoadStuff();">
        <div id="javascriptStatus">
            Javascript NOT detected!
        </div>
        <div id="phoneHomeForJs" style="width: 1px; height: 1px;
overflow: hidden;">
            <img src="/phoneHome.php?javascript=0" />
        </div>
    </body>
</html>


Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux