![]() |
Changing CSS properties depending on browser.
Hi I have been searching google for about an hour now and found a snippet which is said to work. I want to change a property of #nav depending on the users browser being Opera. I'd like to do this with jQuery but this code isn't working and all the examples show this to be the correct way to achieve this.
Here's the code: Code:
if( $.browser.opera ) {Regards, LC. |
testing, ths works fine for me:
Code:
if ($.browser.opera){ |
Where in the source are you inserting it because currently I have it in an external javascript file.
Here is the relevant code:- HTML: Code:
<div id="nav">Code:
#nav {width: 900px;Code:
if( $.browser.opera ) {LC. |
this works fine for me. Having the JS external shouldn't be an issue.
Are you linking to the jQuery and your external JS correctly? View source on your page and click the link to the scripts and make sure they are there. Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
I'll try inserting it into my HTML code because this is what you have done. It's worth a try because I've explored all other avenues that I know. My script links have the correct type and src so I believe it should work.. :S
Edit: Still no change. Do I need to delete my history or something? I haven't deleted it since I started using it and it's the only browser I have trouble with. Please see attatched visual: http://abjava.host22.com/abopera.png. I'm not sure why there is not an equal margin around my content div because in every other browser it is near on perfect. I have a gray div floated left, a gray div floated right and a content div in the middle. I have set the margin to 2.4% but ideally I would like to be able to use margin: auto but everytime I do, the right-floated div ends up below the flow, down the bottom of the page underneath the content div but still floated right. |
looking at your image, it looks like you just might have some "bad" CSS going on. You mind posting the code for that page or a simplified version?
|
Sorry not been able to get on since change. I've successfully achieved what I wanted, it is displaying exactly how I wanted it to. I was not aware you had to put the if statement within a
$(function() {});. It's almost embarrassing, I presumed if it was in an external file, being an if statement it would automatically run.Apologies, LC. |
| All times are GMT +1. The time now is 09:57 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.