top



Is there any way to make a content to be displayed only on some browsers ? (e.g. Only on firefox,opera,IE...) And if yes how ?

THANK YOU !

You could have some JavaScript that determines whether or not to display the content via a user-agent string.

A more detailed help ??? What should I search for ?? And how is it called ?

Nick from UD's tutorial wrote:
Navigator.appName and appCodeName are from the 90's when the only browsers avaiable where internet explorer and netscape.Moreover they will just show the base they are built in (eg netscape or mozilla),since chrome and safari and ff will display "netscape" that wont help!
You have to use the userAgent method for the navigator object,this will show all the info and then you have to use regular expressions to browse through the right version(can also be done with indexOf or test().

Eg :
Code:

ua = navigator.userAgent.toLowerCase();
var browser = {
browserType: (ua.indexOf("opera") != -1) ? "presto" : (ua.indexOf("msie") != -1) ? "trident" : (ua.indexOf("applewebkit/") != -1 && ua.indexOf("khtml") != -1) ? "webkit" : "gecko"
};

Here i used IndexOf to browse through the userAgent object.
Note : the above detects layout engines and not the browser itself.

for mozilla :
Code:
if(browser.browserType.gecko) {
alert("mozilla");
}

edit:oh and we also cant use navigator.product cause even though it displays the layout engine ,in safari it displays gecko as well as webkit,so we cant use it because of that.

The above is properbly the best way, but there is a simple one for IE, which you properbly also know.

Code:
<!--[if IE]>
// content for IE here
<![endif]-->

Unknown Data, for chrome,firefox,Opera would it be like that ???

Code:
<!--[if Chrome]>
// content for Chrome here
<![endif]-->

<!--[if Firefox]>                                          <!--[if Mozila]>
// content for FF here              OR          // content for FF here 
<![endif]-->                                                <![endif]-->

<!--[if Opera]>
// content for Opera here
<![endif]-->

Nope Smile
only for IE

What about the other browsers xD Razz Cant that be done on firefox,chrome,opera ?

read ghost1's post Smile

I read it, but I think ghost1 is reffering to load pages, isn't he ??? I use the widgets show/hide script and Chrome is messing everything up when the user reopens widgets... Firefox does not do so... So I want the button to be displayed on Firefox, IE,Opera but NOT in Chrome... Could you explain me more ??? Sorry for that inconvenience but I am trying to learn Smile

Many many thank's, sgeorge

Then you can use these Smile
Wrap the widget with a div and give it a class
then hide it with CSS:

Code:
.WIDGET CLASS {
        display: none;
    }
then use this CSS to display it in firefox:
Firefox:
Code:
@-moz-document url-prefix() {
    .WIDGET CLASS{
        display: block;
    }
}
and for IE:
put this in the overall_header
Code:
<!--[if IE]>
<style>
    .WIDGET CLASS{
        display: block;
    }
</style>
<![endif]-->

hope this helps Smile

should I add something "url-prefix( HERE )" ?

It is visible in chrome... :(

Nope just leave it as its and change only the div class.

ok

read my post again if its visible in chrome ..you may have not added a div and the CSS

I did but I forgot to add the second <"> xD What about opera ? what should I learn more Smile xD

its now visible only for firefox and IE Smile
or you want to show it in opera too Razz ?

I want to show in opera too xD Smile and one more question, is there any way to hide content only from one browser ??

then you will need to use ghost1's post..
Here you can display the div with CSS for all browsers and hide it for only one Smile

As I can see he hides something for Opera doesn't he ? And isntead of "InderxOf" I will use my div ?

sgeorge wrote:As I can see he hides something for Opera doesn't he ? And isntead of "InderxOf" I will use my div ?

if i remember correctly(since i wrote this a long long time ago) indexOf finds the browser

Trident = > IE's Layout Engine = > Internet Explorer
GEcko = > Firefox Layout Engine
Presto = > Opera's layout engine
Webkit = > Safari & Chrome layout engine

all you have to do is modify the field inside the If conditions Wink

sgeorge wrote:As I can see he hides something for Opera doesn't he ? And isntead of "InderxOf" I will use my div ?

sorry for dp,i dont hide anything its just an If conditional that is just a browser detector and part of Kindle JS library Wink

Then make something for hiding a div Wink

ghost1 where should I add my code that want to be hidden in the 1 browser ?

sgeorge wrote:ghost1 where should I add my code that want to be hidden in the 1 browser ?

what browser do you want to hide?
pion browsers 8es na kripseis?

Go to page : 1, 2  Next