473,246 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,246 software developers and data experts.

How to solve cross domain permission with server proxy?

Hi,

I`m trying to read the href property of an iframe with a javascript that running in the main frame. When the main frame and the inner iframe are both from the same domain I can read it with:
Expand|Select|Wrap|Line Numbers
  1. frames['innerFrame'].location.href
but when the inner frame is served from a different domain I run into cross domain permission issues.

Can I use proxy on my server to solve it?
For example let`s say the main frame urs is http://www.example1.com and the inner frame url is http://www.example2.com.
Can I use my server to let the client browser "think" the main frame is from www.example2.com?
Maybe there is another way around this?

I`m using Apache and I realize it`s not a pure javascript question but it`s related.

Here is a short example to reproduce the cross domain permission issue:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3.     <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5.         <title>iframe test</title>
  6.         <script type="text/javascript">
  7.             var alertHref = function() {
  8.                 alert(frames['innerFrame'].location.href);    
  9.             }    
  10.             window.onload = function() {
  11.                 // the time out just make sure the iframe is ready
  12.                 setTimeout(" alertHref()",3000); 
  13.             };
  14.         </script> 
  15.     </head>
  16.     <body>
  17.         <iframe src="http://www.thescripts.com"
  18.             id="innerFrame"
  19.             width=1000
  20.             height=500
  21.             name="innerFrame">
  22.         </iframe>
  23.     </body>
  24. </html>
  25.  
Thanks
Sep 18 '07 #1
5 3410
acoder
16,027 Expert Mod 8TB
You could use Ajax to make a request to your web server proxy. The proxy would then deal with making the request to the domain.
Sep 18 '07 #2
Could you explain a bit more?

Thanks

You could use Ajax to make a request to your web server proxy. The proxy would then deal with making the request to the domain.
Sep 18 '07 #3
acoder
16,027 Expert Mod 8TB
You could use Ajax to make a request to your web server proxy. The proxy would then deal with making the request to the domain.
Since this is not possible with Javascript, use a server-side script to make the requests/connections. It gets the response and this would become available to the client-side Javascript via the XMLHttpRequest object.

Why do you want the href of the iframe or is that only a test?
Sep 19 '07 #4
I want to know when the href of the iframe changes and to read it`s value. It`s not just a test. I have to do it with javascript and I have a feeling it`s possible with setting reverse proxy of the main frame to be the same domain as the iframe.

Thanks


Since this is not possible with Javascript, use a server-side script to make the requests/connections. It gets the response and this would become available to the client-side Javascript via the XMLHttpRequest object.

Why do you want the href of the iframe or is that only a test?
Sep 19 '07 #5
rnd me
427 Expert 256MB
the big issue here is that frames cannot talk to one another.
so, the info will have to take an alternate route be it the clipboard, an external file, or a server. you you can control scripts on both pages, you can set an onbefroeunload type event to update youre apache server that the frame navigated away, the hard part would be saying where it went. the simplest way could be to make a new image, and set its source to ping your server.
google image pinging...

you would then need to peroidically check the server from the master page to figure out when they left, since the server cannot 'push' info to the browser...
Sep 21 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: CJD | last post by:
Hello, I want to create a server-side object that tracks the clicks of a user while they do a task in a browser. The tasks would take place on external web sites. Since there does not seem to be...
25
by: VA | last post by:
This has come up before but I am not sure if the latest versions of IE and FF change the answer. A script running on a webpage served up by http://foo.something.com should be able to do...
13
by: trpost | last post by:
I am looking to make a small web app that will return the status of a website from the client browser. I tried this with AJAX and it worked great locally, but did not work for remote users...
6
by: Simon | last post by:
Hi All, An experiment i'm doing requires requires a synchronous cross-domain request, without using a proxy. I wondered if anyone had any ideas to help me achieve this. Below is what I have...
1
by: monk125 | last post by:
I have 2 iframes on a page, one of which i want to get it's location everytime it loads (and set an text input to that value). As the iframe is set to a domain not the same as the one where the...
6
by: Bart Van der Donck | last post by:
Hello, I'm presenting my new library 'AJAX Cross Domain' - a javascript extension that allows to perform cross-domain AJAX requests. http://www.ajax-cross-domain.com/ Any comments or...
2
by: lionheartz2003 | last post by:
How to solve a cross domain issue as it is showing "permission denied" error message? Any thoughts?
9
by: Lee | last post by:
Hi all, We need to create a page where we detect the finish of a game that's hosted on another site. We thought of doing it with frames, where we would put the game in an iframe that is...
6
by: ampo | last post by:
Hello. Can anyone help with cross-domain problem? I have HTML page from server1 that send xmlHTTPRequest to server2. How can I do it? Thanks.
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.