Javascript 工具提示视口验证
希望代码验证弹出窗口是否实际位于视口中 比如说if(screenshotWidth+screenshotX>window.innerWidth){//do stuff},然后高度也是一样的,但就我所知 谢谢Javascript 工具提示视口验证,javascript,jquery,tooltip,Javascript,Jquery,Tooltip,希望代码验证弹出窗口是否实际位于视口中 比如说if(screenshotWidth+screenshotX>window.innerWidth){//do stuff},然后高度也是一样的,但就我所知 谢谢 this.screenshotPreview = function(){ /* CONFIG */ xOffset = 10; yOffset = 30; // these 2 variable determine popu
this.screenshotPreview = function(){
/* CONFIG */
xOffset = 10;
yOffset = 30;
// these 2 variable determine popup's distance from the cursor
// you might want to adjust to get the right result
/* END CONFIG */
$("a.screenshot").hover(function(e){
this.t = this.title;
this.title = "";
var c = (this.t != "") ? "<br/>" + this.t : "";
$("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='url preview' />"+ c +"</p>");
$("#screenshot")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.fadeIn("fast");
},
function(){
this.title = this.t;
$("#screenshot").remove();
});
$("a.screenshot").mousemove(function(e){
$("#screenshot")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px");
});
};
// starting the script on page load
$(document).ready(function(){
screenshotPreview();
});
this.screenshotPreview=function(){
/*配置*/
xOffset=10;
yOffset=30;
//这两个变量确定弹出窗口与光标的距离
//您可能需要调整以获得正确的结果
/*结束配置*/
$(“a.屏幕截图”).hover(函数(e){
this.t=this.title;
this.title=“”;
var c=(this.t!=”)?“
”+this.t:”;
$(“正文”)。追加(“”+c+”
”;
$(“截图”)
.css(“顶部”(e.pageY-xOffset)+“px”)
.css(“左”(e.pageX+yOffset)+“px”)
.fadeIn(“快速”);
},
函数(){
this.title=this.t;
$(“#屏幕截图”).remove();
});
$(“a.screenshot”).mousemove(函数(e){
$(“截图”)
.css(“顶部”(e.pageY-xOffset)+“px”)
.css(“左”(e.pageX+yOffset)+“px”);
});
};
//在页面加载时启动脚本
$(文档).ready(函数(){
截屏预览();
});