jQueryで画面サイズを計算するにはどうすればよいですか?jqueryで画面サイズを計算する方法
新しいチャットウィンドウを作成するスクリプトがありますが、4番目のウィンドウを作成すると、画面外に表示されます。私は画面のサイズを計算し、その限界を超えない方法を知るのを助けるでしょう!
function createChatBox(chatboxtitle,chatname,minimizeChatBox) {
$(" <div />")
.attr("id","chatbox_"+chatboxtitle)
.addClass("chatbox")
.html('<div style="cursor:pointer"onclick="javascript:toggleChatBoxGrowth(\''+chatboxtitle+'\')"><div class="chatboxhead"><div class="chatboxtitle">'+chatname+'</div><div id="chatboxoptions"><a href="javascript:void(0)" onclick="javascript:closeChatBox(\''+chatboxtitle+'\')"> X </a></div><br clear="all"/></div><div class="chatboxcontent"></div><div class="chatboxinput"><textarea class="chatboxtextarea" onkeydown="javascript:return checkChatBoxInputKey(event,this,\''+chatboxtitle+'\',\''+chatname+'\');"></textarea> <br clear="all"/></div>')
.appendTo($("body"));
$("#chatbox_"+chatboxtitle).css('bottom', '0px');
chatBoxeslength = 0;
for (x in chatBoxes) {
if ($("#chatbox_"+chatBoxes[x]).css('display') != 'none') {
}
}
if (chatBoxeslength == 0) {
$("#chatbox_"+chatboxtitle).css('right', '215px');
} else {
width = (chatBoxeslength)*(225+7)+215;
$("#chatbox_"+chatboxtitle).css('right', width+'px');
}
}
あなたはとても私たちはあなたの周り – depperm
ブラウザのビューポートを意味するか作業しているか知っているHTMLを含めることができますか? jQueryでは、 '$(window).width()'はそれに必要なものでなければなりません。 (ネイティブjsは単に 'screen'オブジェクトを使用します) – Carl
あなたが必要とするものは、ビューポートのサイズ、画面サイズは役に立たない –