jquery - Show DIV on Mouse Movement Towards Closing Browser Tab Cross-Platform -
my client wants attractive div show when tries move mouse close browser tab, , works cross-platform in latest browsers.
what jquery technique detecting particular kind of mouse movement?
you'll need determine users operating system. can done user agent detection. see question: how check website viewer's operating system?
then, 1 option put fixed position hidden div in corner , on hover, show div.
psuedo code like
html:
<div id="trigger-div" class="trigger-div"></div> <div id="annoying-div" class="hidden">please don't leave me!</div>
css:
.hidden {display: none} // may or may not appropriate. use visibility or opacity .trigger-div {position: fixed; height: 100px; width: 100px; top: 0;} .trigger-div.windows {right: 0;} .trigger-div.mac {left: 0;}
psuedo js:
jquery(function () { var os = navigator.platform; if (os === 'macintel') { jquery('#trigger-div').addclass('mac'); } else if (os === 'win32') { jquery('#trigger-div').addclass('windows'); } else { // maybe consider mobile? jquery('#trigger-div').hide(); } } jquery('#trigger-div').on('hover', function () { ('#annoying-div').removeclass('hidden'); });
Comments
Post a Comment