SORU
4 Ocak 2011, Salı


Nasıl eğer URL bir dize içeriyorsa kontrol etmek için?

Nasıl böyle bir şey yapabildim:

<script type="text/javascript">
$(document).ready(function () {
    if(window.location.contains("franky")) // This doesn't work, any suggestions?
    {
         alert("your url contains the name franky");
    }
});
</script>

CEVAP
4 Ocak 2011, Salı


Href özellik eklemek ve contains yerine indexOf kontrol etmeniz gerekir

<script type="text/javascript">
$(document).ready(function () {
    if(window.location.href.indexOf("franky") > -1) {
       alert("your url contains the name franky");
    }
});
</script>

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • dougownsall

    dougownsall

    7 EKİM 2007
  • Glove and Boots

    Glove and Bo

    1 ŞUBAT 2007
  • PomplamooseMusic

    PomplamooseM

    28 HAZİRAN 2008