2014-03-06 40 views
0

我想知道如何導入特定的JS腳本爲我的移動設備專用的JS腳本...包括自適應設計

事情是這樣的:

</html> 
<!DOCTYPE html> 
<html lang="fr"> 
<head> 
    <meta charset="utf-8" /> 
    <link href="stylesheets/bottom.css" media="screen, projection" rel="stylesheet" type="text/css" /> 
    <link rel="stylesheet" href="components/normalize-css/normalize.css"> 
    <link href="stylesheets/app.css" media="screen, projection" rel="stylesheet" type="text/css" /> 
</head> 
<body> 
    // Only for media screen and (max-width : 500px) 
    <script src="modile.js"></script> 
</body> 
</html> 

回答

0

你可以做些什麼像這樣:

<script> 
    if (window.screen.width <= 560) { 
     // load the script you need 
    } else { 
     // load another script 
    } 
</script> 

您可以使用jQuery getScript加載腳本,例如;