Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. An ordinary Javascript loop works for(i = 0; i < pictures.length; i++) { $(pictures[i]).click(function(){ $(info[i]).fadeIn(200); });}
  2. The reason is that you forgot to specify that the position is in pixels: div.style.left=x + "px";div.style.top=y + "px";
  3. Ingolme

    HTML5

    I was looking into the <hgroup> element the other day as well and found out it was removed from the draft.
  4. I didn't analyze it deeply, but the links probably are being covered up by an element that was positioned ontop of it, so they can't be clicked.
  5. Your website's looking really really strange in Firefox for me. Don't use "position: absolute" because it's just messing up your page. I hate to say it but starting over from scratch using more modern CSS techniques is the probably the best way to get the site to work properly.
  6. Before HTML 5 it was impossible to do with Javascript. With PHP's GD library you could build a program that did it on the server-side.
  7. Canvas is for anything that you want to save in an image format, aside from other uses.
  8. You'll have to rebuild your program using the HTML 5 canvas element if you want to be able to save the result as an image.
  9. Event handlers that are appended as element.onclick will stay when the elements are clones, since they are properties of the element. If you used addEventListener() or attachEvent() then the events won't be cloned.
  10. Anything you create is not linked to the DOM in any way until you use appendChild() to append it to one of the elements in the DOM. That means DocumentFragments and elements created using cloneNode as well. There's only one way to restore event handlers:Every time you create an event handler, remember the path in the DOM that you used and remember what event it was. Every time the DOM is changed you need to check whether the element was removed or not and when it is put back put the event handlers back. This is probably what jQuery does with its on() and live() functions. If you really are planning on cloning, deleting and appending nodes then using jQuery to remember the events is probably easier than trying to build a whole event control system yourself.
  11. Assuming you already have obtained the contents of the file in a string, you can use split() to break it into an array. Now, generate a number using Math.random() to get a random number between 0 and the length of the array. Use that the get an element of the array which will contain one of the strings that were in the text file. Quick example: var str = "word1 word2 word3";var arr = str.split(" ");var num = Math.floor(Math.random() * arr.length);alert(arr[num]) // This will show one random word from the set of words.
  12. Browsers today usually wait for multiple changes before re-rendering. When it comes to DOM efficiency, each case is particular, there isn't a general solution that would solve everything. If you're going to stick with the document fragment idea, there's no need to update the structure 60 times per second. Generate the document fragment the moment you're going to apply changes, do all the changes you want to do, and then append it to the document. The problem with cloning elements and re-appending them is that you'll lose theis event handlers. Overall, don't worry about efficiency until you actually see problems on your website. This might be a case of preemptive optimization.
  13. You forgot to end line 7 with a semi-colon ;
  14. Your document fragment is being managed by the browser in the exact same way the DOM is, so there would be no efficiency benefit. It would actually not be good to have a function running 60 times a second just to manage its own data structure. It's best to just let the browser handle the document, make changes whenever you need them and that's it.
  15. You could apply those styles to your list, or wrap the list in another element with those styles applied to it. I just gave the class selector called "modal" so that you know the styles are intended for the modal box. You can put the rules on any element that you want to give a scrollbar to.
  16. Giving a fixed size is as easy as setting the width and height. To give it a scrollbar, set the overflow property to "auto" .modal { width: 600px; height: 400px; overflow: auto;}
  17. You seem inexperienced with the CSS @media rule if you're suggesting Javascript and separate pages.
  18. You can know if the form was sent by checking if any of the form elements were set. Most often the submit button is used. if(isset($_POST['submit'])) { header('Location: http://website.com/file.php');}
  19. I use Firebug, but other browsers have their own developer tools. In most browsers pressing F12 will open developer tools, which include a console that shows Javascript errors. If you use Firefox but don't have the Firebug add-on, pressing Control+Shift+J will open the Javascript error console.
  20. You haven't checked that the form was submitted. You're telling it to redirect every time. Aside from that, you're sending the header after having used an echo statement.
  21. The string in mysql_query is unclosed. If you had a syntax higlighter it would be very clear: mysql_query("INSERT INTO `backform` (`name` , `email` , `text` )VALUES (`$ime`, `@email`, `$message`)`,$con);mysql_close($con);
  22. Well, that depends on where you call the header() function from. You should tell PHP to only call the header() function after the form is submitted.
  23. I'm getting an error in my console in the showMap function: IndexSizeError: Index or size is negative or greater than the allowed amount It seems that some of the values you're passing to drawImage() are negative or too large. Maybe this line is resulting in a negative number engine.tiles[i][j].type - 1
  24. Just set the array in the included file, then you can work with it normally: a.php $files = array( 'a' => 1, 'b' => 2); b.php include 'a.php';echo $files['a'];
  25. Ingolme

    CSS

    Here's the CSS selectors reference: http://w3schools.com/cssref/css_selectors.asp
×
×
  • Create New...