javascript - How to reload the page on the scroll event? -
i'm trying reload page on scroll event, condition works other methods not window.location.reload()
why not functioning intended?
var $searchbox = $('#searchbox'); var $the = $(window); $the.on('resize', function() { if($searchbox.is(':focus')) { if($the.width() > 940) { window.location.reload(true); }; } });
i not have 50 reputation have use answer field.
i uploaded code here: jsfiddle
html:
<input type="text" id="searchbox" />
css:
#searchbox { width: 100%; } #searchbox:focus { background: #000; }
javascript
var $searchbox = $('#searchbox'); var $the = $(window); $the.on('resize', function() { if($searchbox.is(':focus')) { if($the.width() > 940) { // alert('page reloading'); window.location.reload(true); }; } });
your code works fine if focus input box , pull left border left side page bigger 940px. there won't loop because field has focused.
Comments
Post a Comment