2016-09-12 2 views
-2

내 링크는 https://mytestsite.com/search/label/interesting?m=1href 링크에서 특정 문자를 제거하려면 어떻게해야합니까?

어떻게 링크 끝에서 제거 할 수 있습니까?

+0

처럼 할 수 - arr[0]에서

var link = 'https://mytestsite.com/search/label/interesting?m=1'; var arr = link.split('?'); console.log(arr[0]); 

당신은 결과를 얻을 것인가? –

+0

m이있는 경우 리디렉션을 수행하십시오. – madalinivascu

+0

URL을'?'문자로 분리 할 수 ​​있습니다. 지금까지 뭐 해봤 어? – lharby

답변

-1
var str = "https://mytestsite.com/search/label/interesting?m=1"; 
    str = str.slice(0, -4); 
0

URL을 ? 자로 간단히 나눌 수 있습니다. 당신은 단지 소스에서 제거 할 수 있습니다 https://mytestsite.com/search/label/interesting

1

당신은 단순히이

var address = "https://mytestsite.com/search/label/interesting?m=1"; 
 
var pieces = address.split('?')[0]; 
 

 
// to show address after being sliced 
 
alert(pieces);

+0

요청되지 않은 jQuery 요청을 추가하는 이유는 무엇입니까? – jwpfox

+0

내 대답 편집 –

관련 문제