Jump to content

Ingolme

Moderator
  • Posts

    14,894
  • Joined

  • Last visited

  • Days Won

    176

Everything posted by Ingolme

  1. In general, document.write() shouldn't be used. Alternatives to document.write() are element.innerHTML to add or modify content and console.log() for testing. When called during page load, it will insert the content into the place it was called from. If called after the page has finished loading, it replaces the page with new content.
  2. It's not an array because you overwrote the array with an object of type "component" on this line: gameObstacle = new component(10, 200, "green", 300, 120);
  3. Ingolme

    Form Tutorial Help

    The tags aren't removed, they're just converted into text so that they can't be interpreted as HTML.
  4. I think it may be possible to use embedded SVG filters in the CSS rule. Have the SVG embedded anywhere in your document, but use the CSS rule on the <canvas> element. The same as the original solution, but instead of the SVG being in a different file, it is within the same document: <style> #myCanvas { filter: url("#darkGreen"); } </style> ... <svg> <defs> <filter id="darkGreen"> ... </filter> </defs> </svg> ... <canvas id="myCanvas"></canvas> With this setup (if it works), you will be able to edit the SVG filter with Javascript while also applying the filter to a <canvas> element.
  5. Oh, the filter needs to be applied using the svg filter attribute. I'm not entirely sure what the best way to do it is, I would have to do experiments. Either give a filter attribute to the <html:canvas> element or give it to the <foreignObject> tag. Either this: <html:canvas filter="url(#xPurple)" ... ... > or this: <foreignObject filter="url(#xPurple)"> ... ... If the <foreignObject> tag necessary?
  6. Unfortunately, you can't modify it with Javascript if it is being loaded from another file. To do that, since canvas can be embedded in SVG, that's probably the best way to do it. Just a tweak to your previous code: <svg xmlns="http://www.w3.org/2000/svg" xmlns:html="http://www.w3.org/1999/xhtml"> <defs> <filter id="darkGreen"> <feColorMatrix type="matrix" values="0 0 0 0 0 0 0.5 0 0 0 0 0 0 0 0 0 0 0 0 1" /> </filter> </defs> <html:canvas id="cSave" width="400" height="200" onclick="clickPreview()" style="position:relative; max-width:100%;"></html:canvas> </svg> In this way, you can access the filter as a DOM element and change its values.
  7. Javascript should have control over the volume, it would take a bit of time to write the code to do that. Even then, that's not going to stop people from downloading the whole track for free. If you want to show just a sample, use an audio editor (a free one is Audacity) to make a short track with just the part of the song that you want users to hear and add the fadeout in the edited file.
  8. No, it is much simpler than that. Save your SVG filter in a .svg file, then apply the filter to any object using the CSS filter property: <style> #myCanvas { filter: url("file.svg#darkGreen"); } </style> ... <canvas id="myCanvas"></canvas>
  9. SVG does not have a <canvas> element. The <foreignObject> tag might work to embed an HTML5 <canvas> element but I'm not sure how well <foreignObject> works. Instead of trying to embed the <canvas> in an SVG document, you could put the SVG code in a separate file and load its filter with the CSS filter property.
  10. Ingolme

    Background Image

    You can set the background-position to bottom left
  11. Please do not reply to old topics.
  12. HTML started allowing nesting blocks inside <a> elements when it transitioned to version 5 because there are so many use cases for hyperlink blocks. I still just set the display of <a> elements to "block" with CSS to avoid an unnecessary <div> inside it unless the structure is complicated.
  13. The more general solution would be to have a string containing the name of the method and use the square brackets notation to access it. var methodName = "toUpperCase"; var str = "Hello World!"; var result = str[methodName](); This solution only works with methods that don't take arguments, of course.
  14. The safest way is to decide a list of permitted methods, and then use a switch() statement to choose which one you want to run: var newResult; switch(userSelectedMethod) { case "toUpperCase()": newResult = enteredText.toUpperCase(); break; case "toLowerCase()": newResult = enteredText.toLowerCase(); break; default: newResult = enteredText; } If you tried to generalize further than that, it's likely that the user will break something by putting invalid methods or something that could alter the control of your program.
  15. Use window.open() to open a URL in a new tab.
  16. From the MySQL reference manual ( https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html#operator_like )
  17. Yes, you can use the code provided in the examples to build your website.
  18. I'm a bit late here, but it's OK to use the code examples from the W3Schools website on your own website. They're very simple and could easily be replicated accidentally, so that can't really fall under copyright protection even if W3Schools was interested in protecting it. The only way you would run into legal problems is if you are copying those code samples into tutorials on your own website.
  19. CSS can't do it. Ideally, the server-side language would do it. If this is a plain HTML page with no server-side language, the best option is formatting the numbers correctly when writing the HTML. If none of the previous cases apply, Javascript should be able to modify the numbers. In Javascript, toLocaleString() will format the numbers.
  20. Ingolme

    Why use em?

    Source: https://webdesign.tutsplus.com/tutorials/comprehensive-guide-when-to-use-em-vs-rem--cms-23984
  21. Xpath can't read Java variables. You have to put the variable outside of the string. "//*[contains(text(),'" + x + "')]"
  22. What errors were being shown?
  23. Is this for homework? It's pretty obvious to me, but I wouldn't like to help you cheat at your homework, you wouldn't learn anything. A logical error is when the program compiles and runs just fine, but does not do what you want it to. To identify the logical error in your code, look at what the program is actually doing and compare it to what you want the program to do.
  24. The vh unit is a proportion of the available space in the window. 100vh should fill the window exactly with no scrollbars. If you are getting any scrollbars with 100vh, it's because you have padding, margins or other elements outside of the current one.
  25. Ingolme

    John

    Assuming that all of the table have the same DateTime values and the same number of rows, the query is not too difficult. If the different tables have different date times it becomes more complicated. The simple query would be like this: INSERT INTO `NewTable` (`DateTime`, `Object1Value`, `Object2Value`, `Object3Value`) SELECT t1.`DateTime`, t1.`Object1Value`, t2.`Object2Value`, t3.`Object3Value` FROM `Table1` AS t1 JOIN `Table2` AS t2 ON t2.`DateTime` = t1.`DateTime` JOIN `Table3` AS t3 ON t3.`DateTime` = t1.`DateTime` This may be very slow depending on how many rows there are to copy from the tables.
×
×
  • Create New...