Julian Jelfs’ Blog

Cross-frame dates cannot be serialised by Sys.Serialization.JavaScriptSerializer

Posted in Javascript by julianjelfs on January 15, 2010

Lets say you have a page with two iframes on it (frame A and frame B). In frame A we do this (forget why):

window.testDate = new Date();

and then in frame B we do this:


We will get a stack overflow (in IE7 at least) when using the debug version of the Microsoft Ajax framework and we’ll just get nothing with the release version.

The root cause seems to be that in frame A testDate instanceof Date is true. But if we reference it from frame B it is false. This means that the serialiser does not correctly identify it as a date etc etc.

This is annoying if you are using the serialiser directly, but it is really annoying if you are forced to use it because you are using an MS Ajax script service proxy. I guess I will have to use jQuery to call the script service directly and take charge of serialisation myself using some other JSON library. I have seen it done but I just know it’s going to be painful…

PS – this issue is nicely described here


2 Responses

Subscribe to comments with RSS.

  1. […] instanceof scope problem Posted in Uncategorized by julianjelfs on January 15, 2010 In my previous post I explained how I ran into the problem that dateB defined on frameB would return false if you […]

  2. […] part three Posted in Javascript by julianjelfs on January 24, 2010 So in my previous posts here and here I described a problem I was having with Microsoft Ajax script library serialisation of […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: