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

  • bcbauer

    bcbauer

    7 ŞUBAT 2007
  • kourtneyannmakeup

    kourtneyannm

    19 ŞUBAT 2012
  • The CGBros

    The CGBros

    20 AĞUSTOS 2011