# javascript window.location vs this.location



## peterjcs (Jan 23, 2007)

I would like to know what is the different between javascript window.location and this.location.

When we need to use window.location and this.location?

Any simple example is appreciate. i am new to javascript

Thank you.


----------



## gamerman0203 (Oct 28, 2005)

"this" referrers to whatever the script is in. If you're doing a mousover/out image swap, you can either name the image and refer to the name or just use "this". example: <img src="" name="image1" onMouseOver="document.image1.src=''"> -or- <img src="" name="image1" onMouseOver="this.src=''">

window refers to the top most level of the DOM (document object model). Think of "window" as an all-encompassing container that has everything inside of it (document (web page), images, animations, movies, forms, etc.).


----------

