Jump to content

jeffman

Members
  • Posts

    7,761
  • Joined

  • Last visited

Everything posted by jeffman

  1. You shouldn't need one -- unless you want to scroll higher. There are several techniques you can use for that.
  2. Let's not be hasty. I had a little extra time over the holiday and thought I'd catch up. Good to be here, though.
  3. The scrollIntoView method might be what you need. Apply it to one of the newly created elements.
  4. The thumbs up package seems to use all those technologies and a database as well. Setting up the database might be the trickiest part for you. The tutorial is actually pretty clear. Maybe you should post more specific questions as you move from step to step. Like, tell us exactly where you are in the process and exactly what you're stuck on.
  5. :hover should work with just about anything, so in principle that CSS will work. In practice, it might depend on the size, display, position, z-index, and a few other properties of #over. In the case, the elements might be nested in such a way that only the .buttons container is "aware of" the hover behavior and the images themselves are not.
  6. You'll need to do some very basic server-side scripting. For a simple task like that, a few lines of PHP will do the job. You can even save the data to a file and not have to learn anything about a database. It can be done without AJAX, which means a little Javascripting as well, but the effect will be a lot more user-friendly. Briefly explaining your skill-level in those technologies would be a good next post.
  7. I don't know if I spotted everything, but here are two things that I noticed. addmines.toString() This worries me. If addmines is the function at the top of the post, then first it has no return value to convert to a string, and second you're not executing the function because you have no (parens). var id = 'r' + r + 'c' + c; As far as I can tell (but I'm half-blind) there are no vars called r or c. Did you mean row and col?
  8. 1. Commas separate unique selectors that share a rule set. The rule set will be applied to every selector in a list that is separated by a comma. A comma is not part of a selector, and any selector separated by a comma can be removed from the list without affecting the other selectors that share the same rule set. Listing multiple selectors that share the same rule set is a technique that exists for efficiency. You don't have to paste the same rule set multiple times. 2. When selectors are "chained" with spaces between them, only the last selector in the chain is affected by the rule set. The previous items in the chain specify the ancestry of the last selector (so we can pinpoint it exactly) and any behavioral conditions (like :hover) that must be met. So the first rule set affects the image with ID="up" under all conditions. Separately, it affects the "over" image <i>when</i> the mouse hovers over its ancestor div "buttons." This rule set makes both those elements 100% opaque. The second rule set works affects the same elements in the opposite way. Together, the rule sets are a kind of on-off switch, as you've observed.
  9. Yeah. I assumed Morsusy had handled the first, but I should have caught the second. @Morsusy: Your sample code won't work because the script won't wait while the fadeOut method executes. It immediately executes the attribute method and then attempts to fadeIn. Since the image is still faded in, there is no animation to see except for the image change. That's what I assume will happen, anyway. The good news is, the animation methods allow you to pass a function that will execute after the animation is complete. I haven't tried the code below, but it looks like it should work, or be close to working. I have no idea what happens if the user stops hovering before all the animation is done.$('#item1').hover(function() { $('#bg').fadeOut('slow', function() { $("#bg").attr('src',"image1.jpg"); $("#bg").fadeIn(); } );} );
  10. }};}}; You need two braces, not four. Try this: };};
  11. Or if you just want one removed, add first() or last() to your class selector?
  12. jeffman

    CSS tool?

    Firefox. Tools->Web Developer->Inspect Watch what happens at the bottom and right side of your window as your drag your mouse over various elements. Alternatively, right-click on an element and select Inspect Element from the pop-up menu.
  13. jeffman

    CSS Width Problem

    The problem goes away if you don't use CSS to make the body display as a table. If you are doing that to affect the size, use another technique. In general, you will get unpredictable results if you tell an element to display as something it's not, and this is especially true with table-related elements.
  14. It's a security issue. Just because your page is active in a window does not mean you "own" the window. A user may have 50-pages of history and forms in a window that they don't want to lose. That makes closing the window their choice, not yours.
  15. Store the file in a directory that cannot be accessed by HTML. One way to create a directory like that is to have an .htaccess file in the directory that restricts access. Google that. Now you have to use PHP to download the file programmatically. There is an example of that here. You should Google the different header types so you know what each one does, and when you might have to use different values.
  16. It sounds like you are asking why the text in ALL the tables is blue. Anyway, that is what I see when I view the page. It happens because some browsers add a tbody element to your table even if your HTML does not include a tbody element. This can make some CSS and some JavaScripting unpredictable. One way to fix it is not to use the tbody element selector in your stylesheet, but to use class or ID selectors instead.
  17. jeffman

    String.trim()

    You might find this useful.
  18. I'll call these Strategies 1, 2, and 3. Strategy 1 is seriously deprecated. As a rule, keep javascript out of your tags. Good style separates structure from behavior whenever possible. Strategy 2 is still available and intuitive. I still prefer it. Note that in place of a function name you can use an anonymous function. (Ignore that point if it means nothing to you.) The big drawback to this strategy is that you can assign only one function at a time. The workaround is to create a "container" function that executes multple functions. Another drawback is that, if you link to a poorly constructed 3rd-party script, it might also assign a function to an event listener, and then yours or it would be overwritten. There is a common workaround for that too. Strategy 3 is the W3 standard and eventually all scripts will do that. Unfortunately, it doesn't work in IE versions before 9. There's a workaround here. Strategy 4 is to use jQuery and let it do the work for you. I don't do that because I'm a purist, and I appreciate that you're trying to learn what's under the hood.
  19. jeffman

    Cookies

    Two examples should be clear from the getCookie function. If the ; and = characters were part of the cookie data, the function would fail, or at least be unpredictable, since it expects those characters to be used as delimiters only. You could avoid them, I suppose, but there might be times when your user has a legitimate reason to store them.
  20. jeffman

    CSS class question

    If this is the way your CSS really looksbody{body {color:blue;} Then it is incorrect. All your css from this point on will probably be ignored. You might want something like this: body{color:blue;}
  21. You don't even need to use dummy inputs. Just try loading query/users.php directly into your browser. If you get a blank screen, it's broken. You can test the ajax side by connecting to a script that echoes "hello" and nothing else. EDIT: This is probably not your problem, but you should move your javascript into the head element of your document. Add a doctype, too.
  22. You could track the questions that have been answered in a session variable, a data file, or a database. The best method depends on your requirements. Like, a session variable would be good if the test has a time limit and if the user must do everything over again every time he takes the test. A file or database might be better if you need the answers to persist for some arbitrary length of time (hours, days, forever).
  23. Well, you do not want multiple body tags. Using div elements is a better solution. I hope that when you refer to tables, you mean for tabular data, not as a technique for laying out your document; use CSS for that. Now, in HTML5 you are no longer limited to div elements. Many new elements behave like divs but have different names (section, footer, etc.) to help you label parts of your document more semantically. There is no "main" element that I'm aware of. Most browsers won't care (they'll treat it like a div) but I would not use a non-standard element that way.
  24. Very old-fashioned code sometimes assigned the href attribute the value javascript:void(0) . This is basically a javascript statement that does nothing, so it keeps the link from behaving like a link without really doing anything else. You might also see some sort of "onclick" attribute in the tag also. None of this is good style in HTML5 (or HTML 4, for that matter). It's better to assign event handlers in the main script. It's also better to use some other element besides a link to trigger behavior that is not link-like. (It is appropriate for a link to trigger behavior before it changes the location, but not instead of that)
  25. mycars.lengthis the number of elements in the array object. The goal of the loop is to cycle through all the elements. So it starts with mycars[0] and loops until it reaches the element before mycars[mycars.length]. i=mycars.length uses the assignment operator ( = ), not the test-for-eqality operator ( == ) so the value never changes. i always = mycars.length so the loop never ends. That's why you crashed.
×
×
  • Create New...