Problems referencing frame containing external page

M

Morten Thorsen

Hi frame experts c",) Hope you can help me out on this one

I've got a frameset (index.html) on my server (server A) defining two
frames. Left frame is named "menu" and contains a page (menu.html) which is
located on the same server while right frame is named "main" and contains a
page (main.html) which is located on another server (server B). This page
has a form named "f" with an element named "id". I want to access/read the
value of this element from the left frame, but I get an access denied error.
Can anybody please help me!

Just to test, I've put an exact copy of the page on server B, onto server A,
and then I have no problems accessing the value. I use the following code:

window.parent.main.f.id.value

I've also tested the frame structure (see the code below the line). When the
page in the right frame is located on server B, it seems like the whole
reference to the right frame is lost.

I also get the same results if I put all three documents on my computer and
fire up the site with http://localhost/index.html and set the right frame
source to http://127.0.0.1/main.html

I use IE

Any help is appreciated c",) Thanks!

Best regards Morten.

----------------------------------------------------------------------------
--------------

Show Frame Structure

1. Visit any web site with frames
2. Paste the following into the browser addressbar (remove any line breaks)
3. Watch a window popup which shows the frame heirarchy of the page being
visited

javascript:function
dt0(W,N,fo,i){fo=eval(N);W.document.write('<li>'+fo.name+'['+fo.document.tit
le+'-'+fo.document.location.pathname+']');if(fo.length>0){W.document.write('
<ul>');for(i=0;i<fo.length;i++){dt0(W,N+'.frames['+i+']',undefined,0);}W.doc
ument.write('</ul>');}};function
dt(W,N){W.document.clear();W.document.write('<ul>');dt0(W,N,undefined,0);W.d
ocument.write('</ul>');W.focus();};function
s(){window.open('','W').close();W=window.open('','W','height=500,width=500,r
esizable');dt(W,'top');};s()
 
M

Martin Honnen

Morten Thorsen wrote:

I've got a frameset (index.html) on my server (server A) defining two
frames. Left frame is named "menu" and contains a page (menu.html) which is
located on the same server while right frame is named "main" and contains a
page (main.html) which is located on another server (server B). This page
has a form named "f" with an element named "id". I want to access/read the
value of this element from the left frame, but I get an access denied error.

Yes, browsers implement the same origin policy for scripts to prevent
you from loading a bank login site for instance and then sniff login
data. Unless you have host1.domain.tld and host2.domain.tld where you
can then set
document.domain = 'domain.tld'
in script to allow the access there is nothing you can do besides using
a HTML application (.hta file) for instance on Windows

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/hta/hta_node_entry.asp
or using local pages with Mozilla and then let your script request the
privilege to access the other page.
 
M

Morten Thorsen

Ok. Thanks for your quick and educational answer. I now understand that it's
probably for the best that we're unable to do such references. In this
particular case, I'd sure liked to be able to do it though c",) I don't know
much about the other two solutions of yours, but I guess the result would be
a private, local service and not a public web service. Right?

Morten.
 
M

Martin Honnen

Morten Thorsen wrote:

I don't know
much about the other two solutions of yours, but I guess the result would be
a private, local service and not a public web service.

You can offer an HTA (HTML application) on a public web server but the
user then has to download it like a normal application to run it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top