Javascript: Comment faire pour vérifier si l'URL contient un mot

Je veux vérifier si l'URL dans un Navigateur contient le mot "Bureau" (je commence le fichier html à partir du Bureau). Son url est: "file:///C:/Users/Joe/Desktop/TestAlert.html"

Mais il devrait y apparaître une alerte, mais ca n'a pas fonctionne.

Voici mon code:

<html>
<head>
<script type="text/javascript">
$(document).ready(function () {
    if(window.location.href.contains("Desktop") > -1) {
       alert("Alert: Desktop!");
    }
});
</script>
</head>
<body>
    <h1>Test001</h1>
</body>
</html>

J'ai testé dans Firefox, Chrome et Internet Explorer.
Il serait très gentil, si quelqu'un peut m'aider!

Vous cherchez un query-string paramètre ou toute chaîne de la url ?
utiliser indexOf au lieu de les contient.

OriginalL'auteur Joe SharePoint | 2016-01-07