Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Javascript window.document.body.offsetHeight issue

807607Nov 6 2006 — edited Nov 6 2006
Hi,
I am trying to set the window's height and width in cookie when ever the user resizes using Javascript. I am calling the javascript function on "onUnload" of the body.
But I am able to set the width but i am unable to set the height each and every time the height is getting reduced. Please help me out. I am stuck.

These are the codes I am Using

setCookie("Width_Height",window.document.body.offsetWidth+","+window.document.body.offsetHeight,234329);
function setCookie(c_name,value,expiredays) {
var expiration_date = new Date("January 1, 3000");
expiration_date = expiration_date.toGMTString();
document.cookie=c_name+ "=" escape(value)((expiredays==null) ? "" : ";expires="+expiration_date);
}

On body Onload I am calling getCookie("Width_Height");

function getCookie(c_name) {

if (document.cookie.length>0) {

c_start=document.cookie.indexOf(c_name + "=");

if (c_start!=-1) {

c_start=c_start + c_name.length+1 ;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end));
}
}

alert(""+screen.width+","+screen.height);
return (""+screen.width+","+screen.height);

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 4 2006
Added on Nov 6 2006
1 comment
286 views