How to disable scrolling temporarily?

The scroll event cannot be canceled. But you can do it by canceling these interaction events:Mouse & Touch scroll and Buttons associated with scrolling. [Working demo] UPDATE: fixed Chrome desktop and modern mobile browsers with passive listeners

Convert array to JSON

Script for backward-compatibility: https://github.com/douglascrockford/JSON-js/blob/master/json2.js And call: Note: The JSON object is now part of most modern web browsers (IE 8 & above). See caniuse for full listing. Credit goes to: @Spudley for his comment below

Reload an iframe with jQuery

If the iframe was not on a different domain, you could do something like this: But since the iframe is on a different domain, you will be denied access to the iframe’s contentDocument property by the same-origin policy. But you can hackishly force the cross-domain iframe to reload if your code is running on the iframe’s parent page, … Read more

Changing the image source using jQuery

You can use jQuery’s attr() function. For example, if your img tag has an id attribute of ‘my_image’, you would do this: Then you can change the src of your image with jQuery like this: To attach this to a click event, you could write: To rotate the image, you could do this:

jQuery – Illegal invocation

I think you need to have strings as the data values. It’s likely something internally within jQuery that isn’t encoding/serializing correctly the To & From Objects. Try: Notice also on the lines: You don’t need the jQuery wrapper as To & From are already jQuery objects.

How do I pass the this context to a function?

Javascripts .call() and .apply() methods allow you to set the context for a function. Now you can call: Which would alert FOO. The other way around, passing obj_b would alert BAR!!. The difference between .call() and .apply() is that .call() takes a comma separated list if you’re passing arguments to your function and .apply() needs … Read more