If I open a window with JavaScript (e.g., with window.open()), is there a way, using the handle on the window I opened, to be notified when the URL of the window I opened changes? For example, I'd like to be able to do something like this, generally:
<script type="text/javascript">
function openNewWindowAndNavigateTo(url)
{
var w = window.open(url, "myWindow");
w.addEventListener("locationChange", handleLocationChange);
}
function handleLocationChange(e)
{
alert(e.sourceWindow.newLocation);
}
</script>
<a onclick="openNewWindowAndNavigateTo('SomeDocumentIAuthored.html')">Go</a>
Even if it's browser-specific (this is just for demonstrative purposes), is this even possible? If so, how? Assuming both documents live on the same domain, etc. Can it be done?