How to get Current Page Url by using JavaScript and JQuery ?

Leave a Comment
Hi,

In a following post we will see , how to get Current Page Url values using JavaScript and JQuery.

JavaScript:
Property                                          
Result
window.location.host  
window.location.hostname  
window.location.port    
    8082
window.location.protocol 
  http
window.location.pathname     
     index.aspx
window.location.href            
window.location.hash           
      #tab2
window.location.search     
       ?foo=123

JQuery:
Property                                          
Result
$(location).attr('host'); 
$(location).attr('hostname');    
$(location).attr('port');               
     8082
$(location).attr('protocol');  
 http
$(location).attr('pathname');            
  index.aspx
$(location).attr('href');                 
$(location).attr('hash');         
    #tab2
$(location).attr('search');     
    ?foo=123
Thanks.

Related Post

0 comments:

Post a Comment