Handling WindowState change on client side

The Infocenter for WebSphere Portal has Changing portlet mode and window state on the client side document that describes how you can handle the portlet mode change on the client side

I tried creating a JavaScript function like this

function doWindowState( windowState, div ){
console.log("Entering namespace specific doWindowState ");
console.log("Exiting namespace specific doWindowState ");
return true;
}


but it does not get called when i click on either Maximize or Minimize button but then i tried using the same trick that i used for doPortletMode() blog and created a JavaScript code like this

function PC_<%=portletWindowID%>_doWindowState( windowState, div ){
console.log("Entering PC_<%=portletWindowID%>_ specific doWindowState ");
console.log("Window State " + windowState);
console.log("Window State " + div);
div.innerHTML="Content set on the client side"
console.log("Exiting PC_<%=portletWindowID%>_ specific doWindowState ");
return true;
}


The function gets control when i click on either minimize or maximize button but when i set the div.innerHTML it throws some wiered JavaScript exceptions like this