How to send message from top to iframe (frame) when pages are on different servers?

Z

zalun

Hi

The problem is:
I want to allow partially display my page in iframed version, but only
for one address.

top page (http://location1/top.html) code: <iframe name='iframed'
id='iframed' src='http://location2/iframe.html'></iframe>

I cannot call any function from top or parent in case of security
errors.

I tried to:

1. check if this.name == 'iframed'
This worked unless one click to any link in the iframed page (the
name changes)

2. check top.location value
Breaks in case of security bug

Is there any way to send any information to iframed page or receive any
information about top page?
Of course where page location servers are different ?

Piotr
 
M

Merennulli

Keep in mind that it's rediculously easy to thwart this if someone is
trying to, but it will stop the automated ones:

<iframe name='iframed'
id='iframed'
src='http://location2/iframe.html?inmyframe=true'></iframe>

Then parse out the querystring and make sure it says what you want it
to say.

It's possible that you could use document.referrer instead, but I'm not
sure all the implications of that with how your iframed page moves.
 
T

Thomas 'PointedEars' Lahn

zalun said:
I want to allow partially display my page in iframed version, but only
for one address.

top page (http://location1/top.html) code: <iframe name='iframed'
id='iframed' src='http://location2/iframe.html'></iframe>

I cannot call any function from top or parent in case of security
errors.

Exactly. Search the archives for "Same Origin Policy".
Is there any way to send any information to iframed page or receive any
information about top page?

Generally, no. Especially, the protocols, the second-level domains, and the
port addresses of the two URI references must be the same, or you will have
to use a signed script to request the required privileges (or lower the
security level of the user agent, but that is not recommended).
Of course where page location servers are different ?

The physical location does not matter, the logical one (addressing) does.


PointedEars
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top