参考までに、パーセンテージベースの幅の高さは、要素「rowScroll」の親コンテナーによって異なります。親自体に高さ、幅の情報を与えてみてください...
アップデート:
画面の高さ幅を 50% にするには、次のようにします。
function windowHW() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
return [myHeight,myWidth];
}
function scrollfun()
{
var ob = document.getElementById('rowScroll');
document_dimension = windowHW();
ob.style.height =document_dimension[0]/2;
ob.style.width =document_dimension[1]/2;
}
関数 windowHW は、次のソリューションをわずかに変更したものであることに注意してください。
stackoverflow question: JavaScript - ブラウザの高さを取得する by meder