Hallo,
Ich möchte eine Funktion wie change die ausgeführt wird wenn sich die größe des Browserfenster ändert.
Ich möchte eine Funktion wie change die ausgeführt wird wenn sich die größe des Browserfenster ändert.
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <p id="test"></p> <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> <script> (function() { var i=0; $( window ).resize(function(e) { i++ $('#test').html(i+' Funktionsaufrufe'); }); })(); </script> </body> </html>
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <p id="test"></p> <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> <script> (function() { var resizeWait; $(window).resize(function() { clearTimeout(resizeWait); resizeWait = setTimeout(resizeFinished, 200); }); function resizeFinished(){ $('#test').html('resize finished'); } })(); </script> </body> </html>
<!doctype html> <title>On Resize Finished</title> <p id=test> <script> (() => { var resizeWait, resizeFinished = () => test.innerHTML+='finished'; window.onresize = () => { clearTimeout(resizeWait); resizeWait = setTimeout(resizeFinished, 200); } })(); </script>
t=onresize=e=>clearTimeout(t)&(t=setTimeout(x=>alert('finished'),500))
t=onresize=e=>clearTimeout(t)&(t=setTimeout('alert("finished")',500))
t = onresize = function (e) { clearTimeout(t, t = setTimeout('alert("finished")', 500)); };
s=a=>console.log(a) s(12,x=13,y=14) //Variablenzuweisungen an Funktionsaufruf gehängt console.log(y) //wurde im Funktionsaufruf deklariert clearTimeout(y) //bringt keinen Fehler - wie praktisch
Kommentar