473,398 Members | 2,404 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,398 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 3416
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.