• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

Detect URL change in popup

I am creating a popup window in a private web application. The popup runs a server-side proxy script, which allows users to 'surf' other websites through the proxy. I need to detect when the user clicks a link which results in the user surfing outside of the proxy script. If this happens, I need to pass the external URL which the user is at back into the proxy script as a querystring.

(The proxy script rewrites the links in the pages the user is surfing, but if the links are created in javascript, the serverside script can't fix them, so I must have some client side way of ensuring the client is redirected back 'into' the proxy an external URL is detected)

Example:
So user is surfing through proxy: http://www.mywebapp.com/proxy?url=http://www.otherdomain.com
User clicks a link which proxy has not 'fixed' - User ends up at http://www.otherdomain.com/page2.html
Parent window needs to detect this URL, and redirect the popup back to
http://www.mywebapp.com/proxy?url=http://www.otherdomain.com/page2.html

I am detecting when the URL changes in a popup. This is not the problem.
From the parent window, I can monitor the popup's URL using myPopupName.location.href

Once the popup leaves mywebapp.com, the parent is unable to monitor the URL of the popup so it can redirect back into the proxy? - I get permission denied when I try to read myPopupName.location.href

Any ideas or workarounds appreciated.

0
richardoc
Asked:
richardoc
  • 6
  • 5
1 Solution
 
Michel PlungjanIT ExpertCommented:
Save your application with extension .HTA and you can do whatever you want
http://msdn.microsoft.com/workshop/author/hta/overview/htaoverview.asp
0
 
richardocAuthor Commented:
I need a cross browser solution. Thanks though.
0
 
Michel PlungjanIT ExpertCommented:
Then you need to look into permissions for mozilla. I think you will find you are not going to have an easy time:
http://www.mozilla.org/projects/security/components/signed-scripts.html

look at UniversalBrowserRead
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
richardocAuthor Commented:
Instead of using a proxy, if I opened a frameset, would I be able to access the URL of the main frame from the top/left frame even though the main frame has left my domain?

Or is it a case that there is no way of reading URL information from frames, popups or parent windows if the domain is different?
0
 
Michel PlungjanIT ExpertCommented:
Thatis the case, yes.
Unless you are using what  I outlined above, security settings do not allow this.

Michel
0
 
Michel PlungjanIT ExpertCommented:
So what is the probability and the damage of a user leaving the proxy?
0
 
Michel PlungjanIT ExpertCommented:
You could do this :

try {
  loc = popwin.location.href
}
catch (e) {
  if (e.message.indexOf('access') {
    window.open('popuphome.html','popWinName')
  }
}


Michel
0
 
richardocAuthor Commented:
Basically the proxy is used to select a webpage url, and provide the address back to the parent window which runs the web app.

If they leave the proxy, this method doesn't work, it just breaks.

I think the above javascript just prevents the access denied warning message but doesn't allow the user to continue using the proxy. I need some way of getting the new external url back into the proxy.

The only other option I can see is to run a toolbar like yahoo's, google's, etc, but that will involve the user installing software.
0
 
richardocAuthor Commented:
If the web app domain was a trusted site, would this make a difference in preventing the access denied messages?
0
 
Michel PlungjanIT ExpertCommented:
I actually never tried....

The try catch was to stop the ones that slipped through...

You should be able to catch most of them in your proxy  no?
0
 
richardocAuthor Commented:
Thanks for the help on this. There is no stright forward answer other than using a signed piece of code.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now