Re: Cross domain iframe access
- From: VK <schools_ring@xxxxxxxxx>
- Date: Wed, 21 May 2008 15:54:25 -0700 (PDT)
On May 22, 1:20 am, "Richard Cornford" <Rich...@xxxxxxxxxxxxxxxxxxx>
wrote:
A demonstration might be the following minimal HTML page. If reading the
value of the - location - property of an IFRAME that contained a page
from an different domain neither of the two alerts in the following code
would be shown. But in reality both are shown when the browser is IE,
Firefox or Opera (and very probably all others).
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<script type="text/javascript">
window.onload = function(){
alert(
'frames["test"].location.dummy = '+
frames["test"].location.dummy
); // Expect "undefined".
alert(
'typeof frames["test"].location = '+
(typeof frames["test"].location)
);// Expect "object" (but possibly "function").};
</script>
</head>
<body>
<iframe src="http://www.google.com/" id="test" name="test"></iframe>
</body>
</html>
It is because for two reasons:
1) applicable to Netscape and IE at the time if the events, it was an
emergency security patch to do it anyhow but bulletproof yet quickly.
2) at that time the idea of handled exceptions was in its very
babyhood and "throw" even for programmers was first associated with
stones or money :-) rather than with some programming matters. While
for Java it could have some small sense, throwing any kind of
exceptions in an environment that didn't implement any mechanics for
them would be silly.
So instead a brute force interceptor was planted into property
resolution chain:
on PROPERTY_GET request reaching "location" point the real value is
thrown away and set to undefined (later many producers decided what it
is cleaner to set it to null instead, so this is what you get in say
Gecko builds).
on PROPERTY_SET request reaching "location" point the value to set is
thrown away but PROPERTY_SET_OK reported back. A bit confusing but has
sense as one doesn't break code execution unless it is indeed
necessary to break the code execution. This way one can set any
properties to window.location and the program will keep working as
long as she doesn't try to read them back.
The younger generation of browsers simply emulates this behavior
because it is like DOM 0 - survival compatibility minimum first,
anything else after.
.
- References:
- Re: Cross domain iframe access
- From: Thomas 'PointedEars' Lahn
- Re: Cross domain iframe access
- From: VK
- Re: Cross domain iframe access
- From: Thomas 'PointedEars' Lahn
- Re: Cross domain iframe access
- From: VK
- Re: Cross domain iframe access
- From: Thomas 'PointedEars' Lahn
- Re: Cross domain iframe access
- From: Thomas 'PointedEars' Lahn
- Re: Cross domain iframe access
- From: Richard Cornford
- Re: Cross domain iframe access
- Prev by Date: Re: Calling internal 'public' methods within js objects
- Next by Date: FAQ Topic - How do I POST a form to a new window? (2008-05-22)
- Previous by thread: Re: Cross domain iframe access
- Next by thread: object.onmouseover
- Index(es):
Relevant Pages
|
Loading