As we have a wonderful concept called hooking where we can create a reference to a function and connect another function In the same way can we create a reference to DOM objects. For example can we create a function and hook it to document.location so that whenever document.location is used the other function must be triggered.

  • I understand that certain properties in the DOM don't act like typical objects in javascript, for example window.location.href. Assigning that property to a value triggers the event to change pages, though I'm not sure if it's an overrideable feature in javascript or if it's somehow treated differently by the browser.
    – Neil
    Apr 23, 2012 at 9:32

1 Answer 1


You can't do this. Setting document.location to anything will immediately trigger a redirect to whatever string representation the value has.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.