Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
153
rated 0 times [  158] [ 5]  / answers: 1 / hits: 20520  / 11 Years ago, mon, november 25, 2013, 12:00:00

URL:



http://testwebsite.com/page1.aspx#page/1


I want to split the URL upto aspx using jQuery or Javascript, meant I want to split the URL so that it should be:



 http://testwebsite.com/page1.aspx


I have tried this code;



var url=document.URL;
var arr=url.split('#');
var myoutput=arr[0];


Is it the right way to split? Is there any other way which is reliable and better?


More From » jquery

 Answers
12

You could just use location.host + location.pathname to generate the specific page path instead of trying to split down a string to contain only what you want it to.


[#74080] Saturday, November 23, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ashelye

Total Points: 479
Total Questions: 97
Total Answers: 85

Location: Benin
Member since Fri, Mar 24, 2023
1 Year ago
;