huangs3
asked on
javascript: how to trap the URL change before it actually unload the current webpage?
Hi Experts:
I want to make a webpage named "MainWebPage" such that when I open it from javascript of some external webpage and change its URL, the "MainWebPage" can detect what is going on and stop unloading the current page, instead it process the new URL and do something in javascript correspondingly.
I haven't find out how to do that yet.
If I use the window.onbeforeunload event of the "MainWebPage" window, I will at least need to figure out two things: 1) how to decide whether user is closing the window or changing the URL? 2) if the URL is changing, how to stop the unload of the current page in the "MainWebPage" window?
Please let me know if you have any idea.
Thank you.
My development environment:
-- .NET 4
-- IE 7
-- Silverlight 4
-- Windows XP SP3
-- Visual Studio 2010
I want to make a webpage named "MainWebPage" such that when I open it from javascript of some external webpage and change its URL, the "MainWebPage" can detect what is going on and stop unloading the current page, instead it process the new URL and do something in javascript correspondingly.
I haven't find out how to do that yet.
If I use the window.onbeforeunload event of the "MainWebPage" window, I will at least need to figure out two things: 1) how to decide whether user is closing the window or changing the URL? 2) if the URL is changing, how to stop the unload of the current page in the "MainWebPage" window?
Please let me know if you have any idea.
Thank you.
My development environment:
-- .NET 4
-- IE 7
-- Silverlight 4
-- Windows XP SP3
-- Visual Studio 2010
ASKER
Hi Designbyonyx:
Unfortunately trapping the click-event does not fit my situation, because the URL change in my "MainWebPage" is not done by user clicking links on it...
The way that "MainWebPage" get changed may be done by another IE window running javascript like:
========================== ========== ========== ===
win = window.open("", "MainWebPage");
win.location = "www.xyz.com";
========================== ========== ========== ===
Is it possible?
Thank you.
Unfortunately trapping the click-event does not fit my situation, because the URL change in my "MainWebPage" is not done by user clicking links on it...
The way that "MainWebPage" get changed may be done by another IE window running javascript like:
==========================
win = window.open("", "MainWebPage");
win.location = "www.xyz.com";
==========================
Is it possible?
Thank you.
So I guess I am a little unclear as to what your are wanting. Can you please describe what you want a little clearer... something like:
I have a master "parent" page with two iframes. Iframe A will cause Iframe B to load a new page. I want the "parent" page to intercept this page load and perform some action...
Thanks.
I have a master "parent" page with two iframes. Iframe A will cause Iframe B to load a new page. I want the "parent" page to intercept this page load and perform some action...
Thanks.
ASKER
Hi Designbyonyx:
I will phase my question this way:
"I have a webpage A. Some external program will get its handler and change its URL. I want this webpage A to intercept its own URL change and perform some action."
Is that doable?
Thank you.
I will phase my question this way:
"I have a webpage A. Some external program will get its handler and change its URL. I want this webpage A to intercept its own URL change and perform some action."
Is that doable?
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Open in new window