2013-09-30 33 views
0

當$(文件)。就緒(函數()停止,如果窗口是提前大於350當文檔被加載,停止加載如果這個條件不滿足

$(document).ready(function(){ 
if ($(window).width() > 350){ 
alert ("No!!! stop"); 
// I want to stop loading the page altogether if window is less than 350. 
return false; 
} 
else if ($(window).width() < 350) { 
alert ("Ok continue.") 
} 

感謝。

+0

請學習'Java'和'javascript'之間的區別,然後再繼續。 –

+0

@SotiriosDelimanolis - 我沒有在這裏看到Java的任何提及?我錯過了什麼? –

+1

@TravisJ我編輯了出來。 –

回答

1

$(文件)。就緒(函數()頁面後執行被加載。 你可以做到這一點,如果你把你的JavaScript在你的身體上,所以它會執行之前的頁面加載

<html> 
<body> 
<script type='text/javascript'> 
    //your actions here 
    //for example redirect to empty page that says stop your width is too large 
    //another solution is to spam alerts() and if there is no alerts reload page to spam more 
    //show page with javascript 
    //$("body').html('STAPH') 
</script> 
... 
</body> 
</html> 

我可以有像

0

好,我剛添加

$("div").empty(); 

只是空的所有div如果窗口> 350