Skip to content

Tag: javascript

window.onload include images

Does window.onlaod include image load? or I must use another event for it? I want use ajax call to get HTML document which contains images, but I want show this document when all images are loaded. Answer it does include all webpage’s resource’s load – more information here: https://develope…

Not sure why the method is not returning any value

I know I already have a similar post, but I can’t for the life of me work out what is different between the two snippets – as I can only get the return value from the first example – but not the second example; both methods in the examples return a value. What is even more bizarre (or frustr…

Insert element before tag with vanilla JavaScript

I’m not very familiar with vanilla Javascript, always have worked with jQuery. I tried this so far, but that got the element in the middle of <head> and <body>. Answer It’s pretty simple. Using appendChild method it can be written as short as:

Testing browser extensions

I’m going to write bunch of browser extensions (the same functionality for each popular browser). I hope, that some of the code will be shared, but I’m not sure about this yet. For sure some of extensions will use native API. I have not much experience with TDD/BDD, and I thought it’s good t…

How to avoid ‘cannot read property of undefined’ errors?

In my code, I deal with an array that has some entries with many objects nested inside one another, where as some do not. It looks something like the following: This is giving me problems because I need to iterate through the array at times, and the inconsistency is throwing me errors like so: I am aware that…