Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. You haven't told the loop to end when the user gives a correct answer. The 'tries' variable is still greater than zero so the loop continues.
  2. Youtube does not use the video tag, if you want a youtube video on your page you need to copy the embed code for the video from youtube's website.
  3. It's hard to tell, it could be due to the Javascript moving it to the wrong places. Your code is really outdated, it is almost like the coding style used over 15 years ago. <br> tags are no longer needed for spacing because CSS does this with margin and padding much more accurately. Dimensions of objects aren't usually measured in pixels anymore and instead are flexible to adapt to different screen sizes. Images aren't used for buttons anymore because the text in them isn't readable by browsers or search engines. Javascript is almost never used for effects because CSS can do it easier and more efficiently. It would be ideal for you to read through the HTML and CSS tutorials on W3Schools to become familiar with modern page design practices. I would recommend building your menu basing it on the code I provided in the previous post. You can still use the images for the buttons, the code will still work as long as the images are wrapped in the links.
  4. I don't see your #container item in your stylesheet, and I have no information about the HTML structure to which the CSS applies, so I can't tell what's going on. You could try making a working example of your page. I would recommend against using fixed-width values for your content and would avoid absolute positioning wherever possible. Since I don't have enough information about your situation, I've just made a guess as to what you intended your menu to look like and made a simple example here: https://www.w3schools.com/code/tryit.asp?filename=FQQ3PRA7JYTD Try to read and understand what the code does. It is very simple, the overflow prevents the buttons from being seen when outside of the list, the position is relative rather than absolute because the object only needs to move relative to its original position. I've added a transition effect and a :hover selector to illustrate that the sliding can be done without Javascript.
  5. Can you describe what you see happening incorrectly in your first block of plain CSS code? The negative left position should always behave the same regardless of screen size unless some other CSS is interfering. All of this can be done without the need for Javascript.
  6. URLs can only contain ASCII characters and even among those, query string components need to have =, ? and & escaped. PHP superglobals have their values decoded already, but if you were to access the raw HTTP data you would need to decode it manually. If you are using PHP to generate URLs or send HTTP requests then you have to manually encode the data.
  7. You need to host the video file on your web host as well.
  8. Due to its asynchronous nature, the AJAX response has to be processed in the callback function. There isno way around that. Is there a reason why you can't move those lines of code inside the success function?
  9. Ingolme

    Style <ul>

    You can select any list and change its bullet images. You can also select individual <li> elements and set their bullet images.
  10. Just for reference, the rotate command and other transformations need to be called before drawing the image because it doesn't modify the existing content of the canvas, it just changes the frame of reference for the next objects that are going to be drawn. I can't see anything obviously wrong in your code, but I don't have all the information either. Just as a test, rotate the canvas only 45 degrees, then draw the image at position 0, 0 rather than 255, 255.
  11. It might be rotating around the top left corner of the canvas, if that's the case then the surface you're drawing on is outside of the boundaries of the image. You probably need to translate the origin before or after rotating. To make sure of this, try rotating just 45 degrees first and see what it looks like.
  12. The OR operator in Javascript returns the leftmost operand that evaluates to a boolean true value. In the following code, the variable x gets set to 5 because 0 is false. var x = 0 || 5; When you assign a variable to itself nothing changes: var x = x; When a variable does not exist, its value is undefined which evaluates to boolean false. In the following code the variable x gets set to 5 because an undefined variable is false. var x = x || 5; In conclusion, the code var x = x || []; will do nothing when x already exists but will assign an empty array to x if it does not already exist. The reason that people creating embeddable scripts do this is to prevent the program from breaking when somebody embeds their code more than once in the same document.
  13. Ingolme

    Array cloning

    The slice() method creates a copy of the array, it does not create a reference to the array. After the copy has been made, it can be changed without modifying the original array. /* Two variables pointing to the exact same array */ var a = ["a", "b", "c"]; var b = a; b[0] = "d"; console.log(a[0]); // Prints "d" /* A variable containing a copy of the array in another variable */ var a = ["a", "b", "c"]; var b = a.slice(0); b[0] = "d"; console.log(a[0]); // Prints "a"
  14. Use CSS to set the border to zero, give it a height of one or two pixels and then give it a background color. CSS lets you style any element in any way, even the <hr> element. The specification only indicates how the browser should style the <hr> element by default when no CSS is applied.
  15. It's not correct. Asynchronous is not about the order of execution, that is merely a side effect, but about whether or not the browser should halt loading the page when it comes across a script. HTML just tells the browser what scripts to load and how to load them. As for methods of loading Javascript, there are just two: synchronous and asynchronous. When a script is synchronous, the page stops loading at the point where the <script> tag ended, waits for the entire script to download, then runs the Javascript from the file, then continues loading the rest of the HTML. This really slows down the page from loading which is why it is recommended to have script tags at the bottom of the document or to load them asynchronously. If you load scripts synchronously in the <head> section then the page will be blank until the scripts are done downloading. When a script is loaded asynchronously, the page begins downloading the scripts but continues parsing the rest of the HTML on the page, waiting until the script has finished downloading before running it. The problem with this is that you cannot predict the order in which scripts will run: whichever script downloads the fastest runs first. The defer attribute tells the browser to remember the order in which scripts were in the document, but this behavior is only predictable if all script tags have the defer attribute and not just some of them. Most of the time, the defer attribute is not used for that purpose and instead is just used to be backwards compatible with old versions of Internet Explorer because it does not support the async attribute.
  16. Ingolme

    Array cloning

    In the first example, if you change a, b will also change because they're both pointing to the same thing. In the second example, both a and b can be changed independently of each other because they're two different arrays that merely have identical content.
  17. What your code currently does is to redirect the browser to an image when the video ends. What I think you actually want to do is to display an image in place of the video on the same page. For that, you need to have an <img> element on the page styled the same was as the video that's invisible. When the video ends, hide or delete the video and make the image visible using the style property or DOM methods. Another option is to use Javascript to set the background image property of the container after deleting the video.
  18. I thought they were all zeroed, but looking at the CSS again I notice the <ul> element does not have its left padding removed.
  19. The use of both async and defer is often done because old versions of Internet Explorer only understood the defer attribute. They're not mutually exclusive, async tells the browser to continue loading the rest of the page while the script is being downloaded. The defer attribute works the same, but deferred scripts are executed in the same order as they are in the DOM rather than executing each one the moment they finished downloading. The async and defer properties are explained in detail on this page: https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement In short, x.parentNode.insertBefore(y, x) means to put y right before x in the document. It doesn't matter what or where x or y are as long as they're both DOM nodes. The insertBefore method works like appendChild(), but instead of putting it at the end of the children, it specifies one of the existing children of the node before which the new element should be inserted. W3Schools has a page explaining the insertBefore() method here: https://www.w3schools.com/jsref/met_node_insertbefore.asp
  20. That might be the visited link color. To be sure, you should open the developer tools and check the element. In most browsers you can find the development tools by pressing F12 on your keyboard.
  21. Without seeing the page itself, or at least the HTML, I can only make guesses. It looks as if there are more elements than the ones that your CSS is styling.
  22. Then look at the browser console for errors and find why it's not working.
  23. First, your code is generating duplicate ID attributes, all the checkboxes have the same ID "rcd". You seem to be just making guesses as to how Javascript works instead of trying to understand it, you should take the time to read through the whole W3Schools tutorial for Javascript. What you need in your Javascript is to get a list of checkboxes. There are several functions in the Document Object Model that do that, getElementsByName works best here. function formcheck() { var checkboxes = document.getElementsByName("choice"); var atLeastOneIsChecked = false; for(var i = 0; i < checkboxes.length; i++) { if(checkboxes[i].checked) { atLeastOneIsChecked = true; break; } } if(!atLeastOneIsChecked) { alert("At least one record must be selected in order to DELETE."); return false; } } This code will only work, of course, if your form calls this function during the submit event.
  24. You can put a <script> tag with a src attribute preceding your code. Some people like to use Javascript to generate script tags, but if you can just write the HTML for it I find that to be a better solution. <script src="arrays.js"></script> <script> This code uses the array </script>
  25. CSS can't do it, you will need to use Javascript to set the scrollTop property.
×
×
  • Create New...