我想找到特定窗口屏幕部分的坐标。我必须将这些作为参数传递给某些 JavaScript 函数。此函数将在页面的特定位置(右下角上方 2 英寸)显示工具提示 div,无论访问者使用何种分辨率、屏幕尺寸或浏览器。
有关演示,请参阅此链接 http://www.dhtmlgoodies.com/submitted-scripts/title-to-note/title-to-note.html
最佳答案
<div style="position:absolute; bottom: 2in; right: 0px;">test</div>
编辑:
$(document).ready(function() {
var height = $(window).height();
var width = $(window).width();
alert('width: '+width+'; heigth: '+height);
});
现在要定位你的 div,你只需要绝对定位你的 div
top:height - div 高度 - 2 英寸。
左:宽度 - div 宽度
关于javascript - 如何在每个屏幕上找到特定位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5783007/