473,698 Members | 2,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to solve cross domain permission with server proxy?

54 New Member
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.co m and the inner frame url is http://www.example2.co m.
Can I use my server to let the client browser "think" the main frame is from www.example2.co m?
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 3438
acoder
16,027 Recognized Expert Moderator MVP
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
dolittle
54 New Member
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 Recognized Expert Moderator MVP
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
dolittle
54 New Member
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 Recognized Expert Contributor
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
5084
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 an all incompassing solution to the javascript cross-domain scripting permission problem, I am wondering if anyone has any server-side ideas. The link below proposes to do this, but I can't figure out how. Looking at their code, they are...
25
3258
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 xmlhttp.open("GET","http://bar.something.com",true) But in Firefox 1.5, I get the Permission denied error Why is this? The domain is something.com so I am not crossing domains,
13
12406
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 accessing the page, I ran into the security problem with making a cross domain request. I have been reading that with JSON a cross domain request can be accomplished, but have not been able to find any examples on how to use it or how to get the return...
6
8628
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 tried, including my conclusions/assumptions (which i'll happily be corrected on if it solves my problem!): The requirement not to use a proxy means I can't use the synchronous
1
1532
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 script is, i use a proxy to navigate to that url.... ie http://www.myscriptsdomain.com/proxy.php?url=http://www.urltoview.com Thing is i'm getting permission denied/uncaught exception errors in FF. <script> function frameonload(what) {
6
5479
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 suggestions are welcome. --
2
1974
by: lionheartz2003 | last post by:
How to solve a cross domain issue as it is showing "permission denied" error message? Any thoughts?
9
8830
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 contained in our page. All we need to do is to READ the location.href of that iframe (which is again, from anohter domain, not our domain) - but we can't! According to this MSDN article, http://msdn.microsoft.com/en-us/library/ms533028(VS.85).aspx...
6
3981
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
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9031
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8904
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.