Pages

Thursday, April 09, 2009

AppJet Error

AppJet error in library global/printing.js

JavaScript Error: Cannot call method "write" of undefined (Line 214)

I had this error while I was working on an application at AppJet. It was weird because the code was breaking on a simple print() function.

This error is caused by the fact that “page” variable is used by Appspot as a global variable representing the page to be displayed to the visitor. Page contains Body element (page.body) and print is an alias for page.body.write.

In my case, I was using page in one of the functions to retrieve other page from the web and then parse it internally. This redefined the main page variable and then writing strings on the page would not work anymore.

So, if you happen to get the same error, rename your “page” variable into something else. :)

No comments: