簡體   English   中英

如何檢查 URL 是否包含任何數字或為空?

[英]How to check if the URL contains any number or empty?

大家好,請我需要你的幫助!

我怎么能做這樣的事情:

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

我需要知道我的 Url 索引何時包含某些內容(ID 號)或為空。

這應該可以完成工作:

   if (window.location.href.match(/\d+/g)) {
     alert("your url index is empty");
   }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM