?
Solved

Detect URL change in popup

Posted on 2005-03-31
11
Medium Priority
?
523 Views
Last Modified: 2008-02-01
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
Comment
Question by:richardoc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 13669775
Save your application with extension .HTA and you can do whatever you want
http://msdn.microsoft.com/workshop/author/hta/overview/htaoverview.asp
0
 

Author Comment

by:richardoc
ID: 13669853
I need a cross browser solution. Thanks though.
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 total points
ID: 13669894
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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:richardoc
ID: 13671838
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 13671868
Thatis the case, yes.
Unless you are using what  I outlined above, security settings do not allow this.

Michel
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 13671875
So what is the probability and the damage of a user leaving the proxy?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 13671911
You could do this :

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


Michel
0
 

Author Comment

by:richardoc
ID: 13671963
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
 

Author Comment

by:richardoc
ID: 13671988
If the web app domain was a trusted site, would this make a difference in preventing the access denied messages?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 13672955
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
 

Author Comment

by:richardoc
ID: 13735683
Thanks for the help on this. There is no stright forward answer other than using a signed piece of code.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question