Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>startsWith</title>
  <script type="text/javascript">
    //判断一个网址的类型
    function judgeUrl(str){
      if(str.startsWith('http://')){
        alert(str+':这是个普通网址');
      }else if(str.startsWith('https://'){
        alert(str+':这是个加密网址');
      }else if(str.startsWidth('git://')){
        alert(str+':这是个git地址');
      }else if(str.startsWidth('svn://')){
        alert(str+':这是个SVN地址');
      }else{
        alert('其它!');
      }
    }
    judgeUrl('http://www.baidu.com');
  </script>
</head>
<body>
  <button>http://www.baidu.com</button>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers