[removed].indexOf not working in Javascript

后端 未结 3 1351
粉色の甜心
粉色の甜心 2020-12-03 22:20

Below is what I have.

var myString = \"http://localhost:8888/www.smart-kw.com/\";
alert(myString.indexOf(\"localhost\"));

This give me aler

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-03 22:42

    I found a way to make this work:

    (window.location.href).indexOf("localhost") > -1)
    

    I actually use this for my projects as conditionals and it works just fine.

提交回复
热议问题