Skip to content

Tag: javascript

How to correctly iterate through getElementsByClassName

I am Javascript beginner. I am initing web page via the window.onload, I have to find bunch of elements by their class name (slide) and redistribute them into different nodes based on some logic. I have function Distribute(element) which takes an element as input and does the distribution. I want to do someth…

Malicious JavaScript code

What exactly is this malicious javascript code doing? The website at http://xxx.tld/wp-includes/dtd.php just returns OK. Answer It is: When the iframe is injected into the DOM the browser will make a request to http://xxx.tld/etc. It is most likely doing this to track hits on your site.

Calculating investment values with javascript

I am currently learning javascript. I have created a calculator to find invesment future value. It is giving me an incorrect value when it displays the future value. I have checked the formula several times but it still gives me an error. Also, I have set alerts to appear if the interest is less than 0 or gre…

Catch express bodyParser error

I want to catch the error from the bodyParser() middleware when I send a json object and it is invalid because I want to send a custom response instead of a generic 400 error. This is what I have and it works: But this seems to me a very ugly approach because I’m comparing the error message which could …

jQuery doesn’t respond: JSFiddle?

Here is my JsFiddle link. I’m testing that jQuery works, but it doesn’t. Have I made any mistakes? I have checked documentation of jQuery and everything seems to be okay. What’s wrong? Answer Select the library first as given in the image below Then you can call jQuery as below Check out thi…

Change background-image size in javascript

I have been attempting to put a repeating background image on a website, with the basic CSS however, id like to be able to change the size of the image im using on refresh, using javascript. CSS has the function but unfortunately the COM style object doesnt – see here for what it can do for backgrounds.…