[Koha-devel] Javascript Properties in Basket.js

David Cook dcook at prosentient.com.au
Tue Oct 9 02:09:01 CEST 2012


In several functions (such as writeCookie function) in Basket.js (both 
for the OPAC and the Intranet), the cookie is handled by using 
"parent.opener.document.cookie" or "parent.document.cookie".

Does anyone know why we need to include the parent and opener 
properties? In the case of opener, I can see that the idea is that we're 
trying to reference the main browser window from the pop-up window. 
However, this doesn't seem necessary. From my tests, "document.cookie" 
does the trick just fine without any reference.

Note: The reason for trying "document.cookie" on its own is because 
"parent.opener.document.cookie" and "parent.document.cookie" don't work 
when embedding the OPAC in an iframe on a separate domain.

As for the "parent" property, this seems completely unnecessary. In the 
case of "parent.document.cookie", the script should be running from the 
main browser window. In the case of "parent.opener.document.cookie", the 
"opener" property would be referencing the main browser window from the 
pop-up, so there would be no need for parent.

Tests show that "document.cookie" works fine for adding and removing 
items from the cart.

However, we wanted to check to see if anyone knew why 
"parent/parent.opener" had to stay or if this would create other issues.

-David Cook



More information about the Koha-devel mailing list