Query String in JavaScript

前端 未结 3 1760
伪装坚强ぢ
伪装坚强ぢ 2021-01-20 18:21

By using document.referrer we will get all the reference of URL in JavaScript, such as the following:

http://localhost/testwordpress/wp-admin/a         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-20 18:57

    To get the query string from document.referrer, you can use the split() method:

    var qs = document.referrer.split('?')[1];
    
    if (typeof qs !== 'undefined') {
        // qs contains the query string.
        // this would be "page=thesis-options&upgraded=true" in your case.
    }
    else {
        // there was no query string in document.referrer.
    }
    

提交回复
热议问题