I have a JavaScript file that detects which browser is being used. I'm not sure if this is isn't a proper way to compensate for different browsers, but I'd like to use a different div based on which browser is being used.
I have a very basic page and I'd like to use something like this, but both of my "main" divs are showing up. Is there a way to do this using javascript?
<script>
if(BrowserDetect.browser == "Firefox"){
</script>
<div id="main_Firefox">
</div>
<script>
}
else{
</script>
<div id="main">
</div>
<script>
}
</script>
-
What exactly are you trying to do, could you expand a bit more?Steven– Steven2012年10月02日 00:39:09 +00:00Commented Oct 2, 2012 at 0:39
-
Take a look at this: How to display browser specific HTML?. Basically it is not a good idea to do what you described.Thomas C. G. de Vilhena– Thomas C. G. de Vilhena2012年10月02日 00:40:13 +00:00Commented Oct 2, 2012 at 0:40
-
I'd like to use a different div based on which browser is being used. Firefox is rendering one of my divs lower than other browsers. I was told by @Steven to check out conditional tags.user1406951– user14069512012年10月02日 00:40:46 +00:00Commented Oct 2, 2012 at 0:40
1 Answer 1
You never want to have something like this, you should use one HTML system for everything. And use CSS and conditional tags in CSS to solve any cross browser issues.
Also you shouldn't rely on user agent strings to determine a browser.
3 Comments
Explore related questions
See similar questions with these tags.