Forum Bugs

Problem using jQuery offset with Prince

Hi guys,

Not sure if this is a bug or not or who's responsibility it is, but I'm hoping you can shed some light on it for me. We've run into a warning message with Prince when using jQuery offsets, in jQuery 1.8.3. After doing a bit of digging it seems to boil down to a function in jQuery called getWindow that gets called on the document object. It seems that in Prince both defaultView and parentWindow are undefined on the document and so undefined gets returned to the caller. This causes problems as jQuery tries to access the undefined as an object.

function getWindow( elem ) {
	return jQuery.isWindow( elem ) ?
		elem :
		elem.nodeType === 9 ?
			elem.defaultView || elem.parentWindow :

I was wondering if you could shed any light on this, thanks.
We have not yet implemented this DOM property. Perhaps you could stub it like this:
Element.prototype.parentWindow = window;
Thanks Mike,

I've got it working with:
Document.prototype.parentWindow = window;

I've put that in a file and fed it in as a part of the Prince command, I no longer see the warning messages so I assume it's working. Although it does remind me of another issue, when specifying javascript files from the command line, is there a way to specify that they are included at the end of the document body, rather than before? It was causing a few issues elsewhere in my implementation.

No, not at the moment. But you could register a window.onload event and that will get executed later.
Thanks Mike,

I'll have a look into it and see if I can get it to behave the way I want.