[javascript] 파라미터 제거하기. remove url parameters with javascript or jquery
https://stackoverflow.com/questions/4651990/remove-url-parameters-with-javascript-or-jquery
var url = 'youtube.com/watch?v=3sZOD3xKL0Y&feature=youtube_gdata';
url = url.slice( 0, url.indexOf('&') );
alert( url );
var url = document.createElement('a');
url.href = 'https://developer.mozilla.org/en-US/search?q=URL#search-results-close-container';
console.log(url.href); // https://developer.mozilla.org/en-US/search?q=URL#search-results-close-container
console.log(url.protocol); // https:
console.log(url.host); // developer.mozilla.org
console.log(url.hostname); // developer.mozilla.org
console.log(url.port); // (blank - https assumes port 443)
console.log(url.pathname); // /en-US/search
console.log(url.search); // ?q=URL
console.log(url.hash); // #search-results-close-container
console.log(url.origin); // https://developer.mozilla.org
window.location.replace(window.location.pathname)
https://jsfiddle.net/mill01/hxrejz5L/6/
'프로그래밍 > Script' 카테고리의 다른 글
[javascript] history.pushState ( 화면 전환 ) (0) | 2023.08.08 |
---|---|
[javascript] 새로고침 없이 파라미터 제거/수정. Remove URL parameters without refreshing page (0) | 2023.08.08 |
[JAVASCRIPT] 25 Killer JavaScript One-Liners That’ll Make You Look Like a Pro (0) | 2023.08.03 |
[jQuery] 숫자에 콤마 제거, replace comma (0) | 2023.07.28 |
[jQuery] TEXTAREA 줄 바꿈,캐리지 리턴(carriage return) 치환 (0) | 2023.07.28 |