window.parent.eval problem: Bug in Firefox or in Prototype?

95 views
Skip to first unread message

Mark Reginald James

unread,
Jun 8, 2010, 7:15:39 PM6/8/10
to Prototype & script.aculo.us
Hi,

I'm seeing a discrepancy that only happens in the Firefox browser
(tested on 3.6.3). I'd appreciate any suggestions on whether this is a
bug in Firefox or a bug in Prototype (1.6.1).

If parent.html contains

<head><script src="prototype.js"></script></head>
<body><iframe src="child.html"></iframe></body>

and child.html contains

<body>
<script>window.parent.eval('alert(Object.toJSON([1,2,3]))')</script>
</body>

In all browsers but Firefox, loading parent.html will show the correct
alert

[1,2,3]

while Firefox instead converts the array into a hash:

{"0": 1, "1": 2, "2": 3}

One fix I've found is to also include Prototype in the child

<head><script src="prototype.js"></script></head>

Mark Reginald James

unread,
Jun 8, 2010, 8:34:23 PM6/8/10
to Prototype & script.aculo.us
Hey guys,

After posting this I realised there was a way to remove any Prototype
reference, which made it clear that it's some issue with Firefox.

A test page with the simplified code is at http://advancedcontrols.com.au/parent.html
. FF displays "false", while Google Chrome displays "true".

Anyway, it's useful to have this issue archived here, particularly the
fact that including Prototype in the child is a work-around.


Reply all
Reply to author
Forward
0 new messages