Welcome Guest, Not a member yet? Register   Sign In
browser js detect
#1

[eluser]metaltapimenye[/eluser]
i need to make a script that can verify browser javascript compability is disable or not. is there any idea about the best way to make it work? i've search trough user guide, wiki and forums and got no clue about it.. thx.
#2

[eluser]ejangi[/eluser]
I don't think you'll be able to use PHP to detect JavaScript very effectively to be honest. You're better off using JavaScript to detect JavaScript... Tongue
And/or use progressive enhancement.
#3

[eluser]Muhammad Faisal Shabbir[/eluser]
I also agree with that might be this hard to do with php .But you can done it javascript . For this you have to right your on function of javascript where you can indentify the browser type and then you have to right whole attributes supported by browser.
#4

[eluser]xwero[/eluser]
to check if javascript is enabled you can use the php function get_browser. The function also reveals many other

@Muhammad : if you use jQuery browser detection is already build in.
#5

[eluser]metaltapimenye[/eluser]
@ucantblameme:new tab->wiki's "progressive enchancement"... have no time yet to read it n_n. thx, cos' i hvn't heard this method b4.

@muhammad: i had write a jsc to detec jsc in ci..
Code:
<?php ###at controller##
$jstest=NULL;
            if($this->input->post('jstest')=="ok"){
                $data['jstest_res']=$this->input->post('jstest');
            }else{
                $data['jstest_res']="not_ok";
            }?>
Code:
<body>
<?php ####at view###
echo $jstest_res;
        if ($jstest_res=="not_ok"){?><form name='jsform' id='jsform' method='post' style='display:none' action=''><input name='jstest' type='text' value='ok' />document.jsform.submit();</form><?php }else{ ##...pure php stuff
        }?><body>
have a notice on "echo $jstest_res;" in view page.. it fully functional only if browser (Opera 9.0) takes the same url path. it wont work if F5 pressed >_<..

@xwero:thx.. at the first time i wish to get the "more integrated with CI" kind of answer, but when i see..
Code:
&lt;?php
echo $_SERVER['HTTP_USER_AGENT'] . "\n\n";

$browser = get_browser(null, true);
print_r($browser);
?&gt;

#############  results

Array
(
    ...
    [javascript] => 1,
    ...
)
.. i think this old recipe takes my pan back into fire. woo, lets cook! n_n
#6

[eluser]mr_coffee[/eluser]
Not going to work. That method (get_browser) only shows if the browser is CAPABLE of handling JS... which is always true, even if JS is disabled.
#7

[eluser]TheFuzzy0ne[/eluser]
Trying to identify what browser a user is using is likely to end in tears. There are literally hundreds of plugins for hundreds of browsers that allow you to spoof your user agent. The best way I can think of would be to build a simple JavaScript Framework. It can then test for compatibility by checking for functions/document variables, which is far more reliable. From there it can use the XMLHttpRequest object (if supported), or where it's not you can usually dynamically add a script to the document head.

Hope this gives you some food for thought.
#8

[eluser]mr_coffee[/eluser]
sure, sure. the downside is if the user has javascript disabled rendering your framework inert. I tried out http://garetjax.info/projects/browscap/ and it's a very effective work around to using javascript to sniff the browser type... but it cannot provide the ONE piece of information I want php to have which is: is javascript enabled?
#9

[eluser]andyy[/eluser]
What if a guy ordered a sequence of events like this:

1. jQuery $(document).ready() executes an AJAX function that posts to a method,
2. The method sets a session variable of true and redirects to javascript enabled templates,
3. No javascript = no session variable, another controller method runs and redirects to javascript disabled templates, triggers a modal dialog, etc..
#10

[eluser]Unknown[/eluser]
can you tell me more about this........./////??




Theme © iAndrew 2016 - Forum software by © MyBB