2016-04-04 6 views
0

ich zwei Seitenplatten (panel_Left und panel_Right) öffnen wollen nur if (window.innerWidth> 800) aber immer offen Platte sein, nur eineoffene linke und rechte Seitenwand, wenn (window.innerWidth> 800)

window.onresize = function (event) { 
    if (window.innerWidth > 800) { 
     window.setTimeout(openPanel, 1); 
    } 
    if (window.innerWidth < 800) { 
     window.setTimeout(closePanel, 1); 
    } 
}; 


function closePanel() { 
    $("Panel_left").panel("close"); 
    $("#Panel_right").panel("close"); 
} 

function openPanel() { 
    $("#Panel_left").panel("open"); 
    $("#Panel_right").panel("open"); 
} 


$("#Panel_left").on("panelcreate", function (event, ui) { 
    if (window.innerWidth > 800) { 
     openPanel(); 
    } 
    if (window.innerWidth < 800) { 
     closePanel(); 
    } 
}); 

Wissen I verwendet wird (jquery.mobile-1.4.5.min.js)

+0

Sie html hier hinzufügen? –

+0

Text nachbestellen und Format verbessert – iberbeu

Antwort

0

window.onresize = function(event) { 
 
    if (window.innerWidth > 800) { 
 
     console.log("hi"); 
 
     document.getElementById("left").style.display = "block"; 
 
     document.getElementById("right").style.display = "block"; 
 
     // window.setTimeout(openPanel, 1); 
 
    } else { 
 
     document.getElementById("right").style.display = "none"; 
 
     document.getElementById("left").style.display = "none"; 
 
     console.log("hello"); 
 
     // window.setTimeout(closePanel, 1); 
 
    } 
 
}; 
 
window.onload = function() { 
 
    if (window.innerWidth > 800) { 
 
     console.log("hi"); 
 
     document.getElementById("left").style.display = "block"; 
 
     document.getElementById("right").style.display = "block"; 
 
     // window.setTimeout(openPanel, 1); 
 
    } else { 
 
     document.getElementById("right").style.display = "none"; 
 
     document.getElementById("left").style.display = "none"; 
 
     console.log("hello"); 
 
     // window.setTimeout(closePanel, 1); 
 
    } 
 
}
#left, 
 
#right { 
 
    width: 10%; 
 
    display: inline-block; 
 
} 
 

 
#left { 
 
    float: left; 
 
} 
 

 
#right { 
 
    float: right; 
 
}
<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <title>stack</title> 
 
    
 
    <link rel="stylesheet" type="text/css" href="style.css"> 
 
</head> 
 

 
<body> 
 
    <div id="left">hi</div> 
 
    <div id="right">hello</div> 
 
    <script type="text/javascript" src="controller.js"></script> 
 
</body> 
 

 
</html>

tun Sie dies benötigen? @mo bi

+0

** Ja ** wirklich Es ist was ich tun möchte ** So danke für die Hilfe. ** –

+0

Sie sind willkommen :). Können Sie bitte auf den Pfeil nach oben neben meiner Antwort klicken? – Batman

+0

du bist willkommen ... ja ok –

Verwandte Themen