I am working on a web based kiosk and have no idea how do it in jquery
I use 2 divs div1 is startpage div2 menu if they mouseover a image, div1 hides and div2 comes up and shows the menu. But when people dont use the menu and walk away it needs to switch back to div 1 without refreshing the whole page. also the timed switch to div1 must start when div2 is active.
<div
id="start"
style="display:none;
position:absolute;
right:0px;
top:0px;
width:1680px;
height:1050px;
background-image:url(start/images/overlays/start_overlay.png);
background-color:;
padding: 0px;
z-index:7;
"> start content here <br> <a
onmouseover="ShowContent('menu'); return true;"
href="javascript:ShowContent('menu'); HideContent('start'); ">
[image]</a>
<div>
<div
id="menu"
style="display:none;
position:absolute;
right:0px;
top:0px;
width:1680px;
height:1050px;
background-image:url(start/images/overlays/menu_overlay.png);
background-color:;
padding: 0px;
z-index:7;
"> Menu Content here </div>
<script type="text/javascript" language="JavaScript"><!--
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "none")
{ document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}
</script>
As I understand you want to show div1 by default, then show div2 when user begins interacting with page and go back to div1 after some time of user inactivity.
$(function(){
var activeTime = 3000,
activeTO;
$(document).on("mousemove keydown scroll", function(){
$("#div1").hide();
$("#div2").show();
clearTimeout(activeTO);
activeTO = setTimeout(kioskIdle, activeTime);
});
function kioskIdle(){
$("#div1").show();
$("#div2").hide();
}
});
Working demo: http://jsfiddle.net/rXjMV/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.