Skip to content

How to prevent IFRAME from redirecting top-level window

Some websites have code to “break out” of IFRAME enclosures, meaning that if a page A is loaded as an IFRAME inside an parent page P some Javascript in A redirects the outer window to A. Typically this Javascript looks something like this: My question is: As the author of the parent page P and not…

Determine when an user is typing

I am building a search box (input field) which should make a server call to filter a grid with the text being inserted on it but I need to make this in an smart way, I need to fire the server call only if the user has stopped. Right now I’m trying to implement it, but if someone knows how

How to append something to an array?

This question’s answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions. How do I append an object (such as a string or number) to an array in JavaScript? Answer Use the Array.prototype.push method to append values to the end …

Avoiding a Javascript race condition

My users are presented a basically a stripped down version of a spreadsheet. There are textboxes in each row in the grid. When they change a value in a textbox, I’m performing validation on their input, updating the collection that’s driving the grid, and redrawing the subtotals on the page. This …

Get the name of an object’s type

Is there a JavaScript equivalent of Java’s class.getName()? Answer Is there a JavaScript equivalent of Java’s class.getName()? No. ES2015 Update: the name of class Foo {} is Foo.name. The name of thing’s class, regardless of thing’s type, is thing.constructor.name. Builtin constructors…

caching JavaScript files

Which is the best method to make the browser use cached versions of js files (from the serverside)? Answer Have a look at Yahoo! tips: https://developer.yahoo.com/performance/rules.html#expires. There are also tips by Google: https://developers.google.com/speed/docs/insights/LeverageBrowserCaching