Ricki
Ricki

Reputation: 943

Is there a way to change values of elements if they use a specific browser?

For example, if in php i printed this:

<script type="text/javascript">

txt = "<p>Browser Name: " + navigator.appName + "</p>";
document.getElementById("example").innerHTML=txt;

</script>

and used a variable, lets say $bname then used an if() statement, could i change the value of an element such as a link <a> etc. to whatever i wanted? alternatively is there a way in jQuery/JavaScript?

Upvotes: 4

Views: 68

Answers (2)

tiltdown
tiltdown

Reputation: 461

You can easily achieve this on jQuery. Using jQuery.browser as easy as this example.

    if ($.browser.webkit) {
     //do stuff for webkit browsers
    }

Upvotes: 2

Orbling
Orbling

Reputation: 20602

$_SERVER['HTTP_USER_AGENT'] may be used PHP side.

Alternatively, with jQuery, you can use the $.browser flags.

Upvotes: 3

Related Questions