Following steps are required for showing a popup on mousehover on a link
Step1: Attach the javascript file from
http://code.jquery.com/jquery-1.6.3.min.js
Step2: Write the following internal stylesheet under the head section of an aspx page
.tooltip {
width: 25%;
padding: 5px;
background-color: white;
border: 3px solid rgb(195,151,51);
border-radius : 5px;
}
.trigger {
border-bottom: 1px dashed white;
cursor : help;
}
.trigger:hover {
color: rgb(255,0,0);
}
Step3: Write following script under head tag of an aspx page
script type="text/javascript">
$(document).ready(function () {
$('.trigger').mouseover(function () {
var ttLeft,
ttRight,
$this = $(this),
$tip = $($this.attr('data-tooltip')),
triggerPos = $this.offset(),
triggerH = $this.outerHeight(),
triggerW = $this.outerWidth(),
tipW = $tip.outerWidth(),
tipH = $tip.outerHeight(),
screenW = $(window).width(),
scrollTop = $(document).scrollTop();
if (triggerPos.top - tipH - scrollTop > 0) {
ttTop = triggerPos.top - tipH - 10;
} else {
ttTop = triggerPos.top + triggerH + 10;
}
var overFlowRight = (triggerPos.left + tipW) - screenW;
if (overFlowRight > 0) {
ttLeft = triggerPos.left - overFlowRight - 10;
} else {
ttLeft = triggerPos.left;
}
$tip.css({
left: ttLeft,
top: ttTop,
position: 'absolute'
}).fadeIn(200);
}); // end mouseover
$('.trigger').mouseout(function () {
$('.tooltip').fadeOut(200);
}); // end mouseout
}); //end ready
Step 4: To test the script is working or not create a link under the body tag
1 Comment(s)