|
User #7319 4055 posts
Whirlpool Forums Addict
|
Hi all, I'm having a bit of trouble getting rid of a white dotted border around an anchor. I think it's something i'm doing wrong regarding the use of text-decoration but I can't work out what i'm doing wrong. If you have a look at http://flighttracker.gleff.com and open the flight panel, and then click on one of the two options in the Aircraft list. You'll notice a white dotted border around the word ALL or QFA456 (depending on what you clicked). I'm trying to do two things. 1. Remove that dotted border after you click the option I've got the following: <ul> <li><a id="ALL" href="ALL" onclick="menuoption('All');return false;" name="ALL">All</a><br /><span class="airline">Track all Aircraft</span></li> </ul> And the following CSS: #content_flightlist ul #content_flightlist li #content_flightlist li a:hover #content_flightlist li a .airline I've tried adding a #content_flightlist li a:visited section but that doesn't help. I've also tried putting text-decoration: none; all over the place but nothing seems to work. I think I must be inheriting something from somewhere. If anyone can help it would be appreciated. |
reference: whrl.pl/RccBfb
posted 2010-Mar-13, 6pm AEST
|
|
User #166340 934 posts
Whirlpool Enthusiast
|
I don't get the dotted border at all in chrome or ie 6. 2. Change the colour of the active option eg. if you click on ALL, then ALL stays the colour red until you click a new option. You could use javascript to add a style depending on which element was clicked, and remove it for the other options, perhaps something along these lines:
|
reference: whrl.pl/RccBgj
posted 2010-Mar-13, 6pm AEST
edited 2010-Mar-13, 6pm AEST
|
|
User #7319 4055 posts
Whirlpool Forums Addict
|
I just saw your post a minute ago and tried the outline-style: none; and that fixed the first issue. If it's not doing it in chrome, or IE6, even better, hopefully it shouldn't do it in any now ;) Now just to work out the second part. |
reference: whrl.pl/RccBg7
posted 2010-Mar-13, 6pm AEST
|
|
User #7319 4055 posts
Whirlpool Forums Addict
|
You could use javascript to add a style depending on which element was clicked, and remove it for the other options, perhaps something along these lines: That's an idea.. I'll try that as a last resort though.. I would think I should be able to do it in CSS so i'll try and get it working there first, and if I don't succeed I'll try the javascript method. Thanks. |
reference: whrl.pl/RccBhV
posted 2010-Mar-13, 6pm AEST
|
|
User #166340 934 posts
Whirlpool Enthusiast
|
I just saw your post a minute ago and tried the outline-style: none; and that fixed the first issue. No wonder. I saw it once, made the post, then went back to look at the second problem and found the first problem was gone, I'd thought it wasn't outline at all :P Incidentally, you should note that your transparent curved border bit on the Flight Panel comes out camel brown in IE6, because this browser doesn't support PNG alpha transparencies. It needs help with pngfix, or you can just convert it to gif with normal transparency. For more info on the second problem, try this: http://api.jquery.com/addClass/ I would think I should be able to do it in CSS I don't remember this being the case. I have the feeling you'll end up doing in javascript. I don't see why not, the entire Flight Panel is jqueried :) |
reference: whrl.pl/RccBh7
posted 2010-Mar-13, 6pm AEST
edited 2010-Mar-13, 6pm AEST
|
|
User #7319 4055 posts
Whirlpool Forums Addict
|
No wonder. I saw it once, made the post, then went back to look at the second problem and found the first problem was gone, I'd thought it wasn't outline at all :P Actually, it would still exist because the changes are only local on my development machine at present.. but obviously the outline issue only affected some browsers.. now hopefully it won't be a problem on any. Thanks for the heads up for IE6. I'm not sure if i'll bother trying to fix it though. I thought it already had the ie6 fix in place but since I don't really want to support ie6 i'm not sure if i'll bother trying to fix it. i'll look into the jquery addclass bit. that sample code on the page you supplied looks easy enough. Thanks for all the help. |
reference: whrl.pl/RccBiB
posted 2010-Mar-13, 6pm AEST
edited 2010-Mar-13, 6pm AEST
|
|
User #166340 934 posts
Whirlpool Enthusiast
|
Thanks for the heads up for IE6. I'm not sure if i'll bother trying to fix it though. I thought it already had the ie6 fix in place but since I don't really want to support ie6 i'm not sure if i'll bother trying to fix it. Fair enough, too. I hate IE6 with a degree of prejudice normally reserved for greater evils. Sadly there's a whole bunch of entrenched users out there who bleat about stuff not working in IE 6, so I keep it around for this reason. It's your site though ;) |
reference: whrl.pl/RccBi6
posted 2010-Mar-13, 6pm AEST
|
|
User #7319 4055 posts
Whirlpool Forums Addict
|
I'm just trying the jquery example and it doesn't appear to be working.. I'm assuming i'm just doing something stupid here. In the index.html I am calling the latest version of jquery which is 1.4.2 I also call a javascript file called controller.js which contains: function menuoption(test) } In the CSS, i've added: .selected { color:red; } For some reason it's not working. I assume whatever i'm doing wrong, it has to do with the a:last part but i'm not sure. |
reference: whrl.pl/RccBo2
posted 2010-Mar-13, 7pm AEST
|
|
User #166340 934 posts
Whirlpool Enthusiast
|
For some reason it's not working Unless you show us how you're using it, why you think it's not working, and what you're using it on, it's kind of counterproductive. So show us. This is a habit a lot of people should get into (describing the problem) rather than just saying "it doesn't work" because nobody knows the context in which you're trying to make it work. |
reference: whrl.pl/RccBpM
posted 2010-Mar-13, 7pm AEST
edited 2010-Mar-13, 7pm AEST
|
|
User #7319 4055 posts
Whirlpool Forums Addict
|
Unless you show us how you're using it and what you're using it on, it's kind of counterproductive. So show us. Not sure what you mean.. Essentially, when you click on one of the options (in this case either ALL or QF456, it runs the menuoption function which in turn calls the addclass which creates the selected class. The selected class in the CSS turns the anchor red and stays that way until I choose another option whereby I'd do the same thing. When I say it doesn't work, I mean it has no affect than if I hadn't used the addclass and selected class. In other words, you'll notice that the page doesn't do anything different when you click on one of the links. |
reference: whrl.pl/RccBq5
posted 2010-Mar-13, 7pm AEST
|
|
User #166340 934 posts
Whirlpool Enthusiast
|
Not sure what you mean.. When I say it doesn't work, I mean it has no affect than if I hadn't used the addclass and selected class. In other words, you'll notice that the page doesn't do anything different when you click on one of the links. This is what I mean. We are not telepathic, we can't see inside your head to interpret "it's not working". People should tell us why they think something's broken, what it should be doing and what it currently does. It really helps us help you. Anyway, here's an example and I recommend you don't just trial-and-error with examples straight into your project. You should learn how to use the functions first, usually in a fresh index.html just to see how it works.
|
reference: whrl.pl/RccBvz
posted 2010-Mar-13, 7pm AEST
edited 2010-Mar-13, 7pm AEST
|
|
User #7319 4055 posts
Whirlpool Forums Addict
|
Thanks for that.. i'll have a go. |
reference: whrl.pl/RccBxf
posted 2010-Mar-13, 7pm AEST
|
|
User #7319 4055 posts
Whirlpool Forums Addict
|
I'm making some progress. Now if you have a look at the site, the active link has a border around it so it proves the addclass and removeclass are both working. It's getting the white border from the .selected in my CSS file. So I have the following: CSS contains: .selected HTML contains: <ul> <li><a id="ALL" href="#" onclick="menuoption('All');return false;" name="ALL">All</a><br /><span class="airline">Track all Aircraft</span></li> </ul> Javascript file contains: function menuoption(test) } } What's supposed to happen in addition to the white border is the text colour should turn red. Instead, it keeps turning off white eg. #e5e5d5. Note: The white border will not be in the final site, it's just to demonstrate the addclass and CSS is working. It must be inheriting it, but i'm not sure how to force it not to inherit. Arrrgh! EDIT: Okay.. figured out what I was doing wrong. Instead of having just a .selected, I changed it to #content_flightlist li .selected Now it's working as intended. |
reference: whrl.pl/RccBQf
posted 2010-Mar-13, 9pm AEST
edited 2010-Mar-13, 9pm AEST
|
|
User #210173 1039 posts
Whirlpool Enthusiast
|
Hi gleff, Interesting project you're working on there. Just wanted to make note that I'm still getting the white border on the panel toggle button, is this intended? (FF 3.5) If its not, you can blanket fix your anchors from getting the outline by using Also, the current method you're using for the active state on your links is a little clunky. Ironheart mentioned using jQuery earlier, its much cleaner and far more flexible for you should you need to add more links later I extracted the menu items from your site and tested this myself. $('#content_flightlist ul li a').click(function(){ This also means you can remove the empty class attributes from your HTML, which is also a little messy. <div id="content_flightlist" style="overflow: hidden; width: 175px;"> <li><a name="QFA456" onclick="menuoption('QFA456');return false;" href="#" id="QFA456">QFA456</a><br> <li><a name="QFA789" onclick="menuoption('QFA789');return false;" href="#" id="QFA789">QFA789</a><br> I changed the href values to "#" but you can amend these how you see fit. Lastly, any reason for the inline styling on the content_flightlist div? Could extract that into your main.css as well as anything else inline. Unless of course its being created on the fly then please ignore. Hope some of that helps. |
reference: whrl.pl/RccD6B
posted 2010-Mar-14, 4pm AEST
|
|
User #7319 4055 posts
Whirlpool Forums Addict
|
Just wanted to make note that I'm still getting the white border on the panel toggle button, is this intended? (FF 3.5) Thanks for that.. is that any better? I'm using FF3.6 and don't see the outline. I've added the a {outline:none} to the main.css Also, the current method you're using for the active state on your links is a little clunky. Ironheart mentioned using jQuery earlier, its much cleaner and far more flexible for you should you need to add more links later I'm using the jquery in the controller.js as: $('a').removeClass('selected'); I'm not using the jquery click function because I'm essentially already using a function in the links. I changed the href values to "#" but you can amend these how you see fit. I'll change this now. Just forgot to do it before.. thanks. Lastly, any reason for the inline styling on the content_flightlist div? Could extract that into your main.css as well as anything else inline. Unless of course its being created on the fly then please ignore. The list of aircraft in the content_flightlist will be created on the fly. I'm just getting the formatting the way I want it so it's easier when I start the jquery/javascript coding. Currently all the data seen is bogus and static. I'll be using jquery to parse an xml file and then creating the flight list on the fly. I wrote a vb .net application that parses the output from my virtual radar box and creates an XML output which I'm uploading to my webhost every 10 seconds. eg. http://www.flighttracker.gleff.com/getdata/aircraft.xml Hope some of that helps. Sure does.. much appreciated. I'm going on holidays in a couple of weeks so I'll start the coding then. I'll probably seek assistance on occasion from good 'ole Whirlpool ;) Let me know if the outline still exists. I think it will in IE because I don't think it supports outline. (IE is the bain of my existence). |
reference: whrl.pl/RccEdg
posted 2010-Mar-14, 5pm AEST
|
|
User #166340 934 posts
Whirlpool Enthusiast
|
I'm not using the jquery click function because I'm essentially already using a function in the links. This is really not a good way of doing it. You'll slash your wrists over it later, I think. I think it will in IE because I don't think it supports outline. IE supports outline if you use a doctype (which I assume is the case) |
reference: whrl.pl/RccEfk
posted 2010-Mar-14, 5pm AEST
|
|
User #7319 4055 posts
Whirlpool Forums Addict
|
This is really not a good way of doing it. You'll slash your wrists over it later, I think. What's wrong with the way i'm doing it.. or better yet, what is the advantage to doing it the other way? So far, I see my current method as being sufficient, but i'm definitely open to another way if there's a good reason for it. Can you explain? Basically, the flight list will be created on the fly using jquery. The click event as it currently stands runs the menuoption function and passes the hex code to it (actually at the moment it's the callsign, but will be the hex code). I'll then process this and other data. IE supports outline if you use a doctype (which I assume is the case) I didn't realize this. I am using a doctype. I just thought it wasn't supported. I just noticed though that since I put the a outline: none; into the main.css it's fixed it for me.. So that's great news. |
reference: whrl.pl/RccEh1
posted 2010-Mar-14, 5pm AEST
edited 2010-Mar-14, 5pm AEST
|
|
User #166340 934 posts
Whirlpool Enthusiast
|
what is the advantage to doing it the other way? It abstracts the javascript from the html. Unobtrusive coding means you aren't presented with a mammoth wad of junk when you edit code. With jquery, there is a massive plus because of its selection ability: eg. $('a').each(function() {...}); allows me to apply a behaviour to *all* anchor tags on a page.
Using your way, you'd have to manually search for and add these behaviours manually. <a onclick='menustyle();'>blah</a> What if you wanted to change the function from menustyle() or whatever you used, to something else? What if it were a mix of two functions? What if you want to do more than just menustyle(); and wanted to do say, buttonstyle() and imagestyle() as well? Suddenly your links become something horrific like this all over the place:
It's clunky, unwieldy and *obtrusive*. And yes, there was a time when I used to do it like this. Then I found jQuery and life was much, MUCH better. This is much easier to read and therefore maintain, fix and extend:
I can add mouseover, mouseout states *to every anchor tag* just as easily without even TOUCHING the html itself, not needing to modify crap inline, saving myself the headache of wondering: "have i actually done this for all the anchor tags, or are there one or two missing somewhere? Why doesn't this particular one work?"
Unobtrusive javascript is something that really should be drilled into beginners, rather than letting them pick up bad habits and run with them. It's for these kinds of reasons I am loathe to use some other dude's script without having at least considered rebuilding it myself (unless of course, it's already good to start with) Other benefits: 2. the HTML file itself is smaller and easy to edit, because it's clean and javascript free (this also allows you to utilise Strategic Division of Labour, where you have a javascripter who can program things independently of the HTML guy who doesn't need to have knowledge of javascript to move crap around on his page). I suppose you might think of it as Three-and-a-half tier architecture or something like that. 3. Because of (2) it's easier for people to read and fix ;) |
reference: whrl.pl/RccElh
posted 2010-Mar-14, 6pm AEST
edited 2010-Mar-14, 6pm AEST
|
|
User #7319 4055 posts
Whirlpool Forums Addict
|
Thanks Ironheart. Makes sense. I'll give your way a bit of thought before deciding whether to rewrite that part. I invision that I may only have to update one line anyway for this particular click event since all the flight list items will be built automatically from one master line. Having said that, this is how I learn, by trial and error. It's good to get other ways of doing it, and often I may re-write sections. Thanks for the explanation. Much appreciated. |
reference: whrl.pl/RccEnf
posted 2010-Mar-14, 6pm AEST
|
|
User #166340 934 posts
Whirlpool Enthusiast
|
Having said that, this is how I learn, by trial and error. It's good to get other ways of doing it, and often I may re-write sections. It's how I did it. I've done things the wrong way so many times, too :P |
reference: whrl.pl/RccEoX
posted 2010-Mar-14, 6pm AEST
|
|
User #210173 1039 posts
Whirlpool Enthusiast
|
is that any better? Bingo. I'm not using the jquery click function because I'm essentially already using a function in the links. Looks like you've been sorted on this now too. I'm fairly certain you'll have a light bulb moment when you realise the suggested method works in your favour! |
reference: whrl.pl/RccE0O
posted 2010-Mar-14, 8pm AEST
|
|
User #7319 4055 posts
Whirlpool Forums Addict
|
ok.. I've re-written that section.. and you're both right.. It's radically simplified things. I'm now controlling the click function from the document.ready as well as the addclass and removeclass. Now my controller.js contains nothing but an if/else statement and a temporary alert command. Should make it much easier to code now. I've also radically reduced the link size. Thanks heaps for the suggestions and help. |
reference: whrl.pl/RccFRl
posted 2010-Mar-15, 4am AEST
edited 2010-Mar-15, 4am AEST
|
|
User #10416 4350 posts
Whirlpool Forums Addict
|
Just a note, I use unobstrusive JS, only because it's the better alternative, but it's definitely not without its flaws. While replacing the inline onclick event with unobtrusive JS is what I would have done, there are a couple of things to consider: 1) an inline event declared is immediately attached to the element when it's loaded onto the page, therefore, it doesn't have to wait for the document.onready event to trigger 2) an inline event is applied to that element, and that element alone; you don't need to worry about performance issues with poor usage of selectors. For point 1, I'm hoping they'll release a new version of JavaScript that has onready event for all DOM elements. For the second point, if you're selecting by class or tag name, you should give it a context. For example, you could change your "tabs" from class to id and do: $('li', $('#tabs')).click(function() { ... });
|
reference: whrl.pl/RccFY0
posted 2010-Mar-15, 7am AEST
|
|
User #7319 4055 posts
Whirlpool Forums Addict
|
Just a note, I use unobstrusive JS, only because it's the better alternative, but it's definitely not without its flaws. While replacing the inline onclick event with unobtrusive JS is what I would have done, there are a couple of things to consider: Thanks for that. Duly noted. I think in this case though, there's no point in changing what's working, and working pretty well imho. |
reference: whrl.pl/RccJpJ
posted 2010-Mar-15, 9pm AEST
|