Reputation: 446
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>
Upvotes: 0
Views: 87
Reputation: 13975
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.
Upvotes: 2