반응형
반응형

[javascript] 파라미터 제거하기. remove url parameters with javascript or jquery

 

https://stackoverflow.com/questions/4651990/remove-url-parameters-with-javascript-or-jquery

 

remove url parameters with javascript or jquery

I am trying to use the youtube data api to generate a video playlist. However, the video urls require a format of: youtube.com/watch?v=3sZOD3xKL0Y but what the api generates is: youtube.com/wa...

stackoverflow.com

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/

 

반응형
반응형

 [JSP] 현재 URL 가져오기

Context : <%= request.getContextPath() %>

URL : <%= request.getRequestURL() %>

URI : <%= request.getRequestURI() %>

Path : <%= request.getServletPath() %>

 

URL은 Uniform Resource Locator

URI는 Uniform Resource Identifier

URI(동물) 가 좀더 상위 개념이라서 URL(강아지), URN(다람쥐) 등의 하위 개념을 포함한다.

URI 와 URL 이 아예 다른게 아니라 포함관계라서

모든 URL 는 URI 이다. 가 성립힌다. (TRUE)

URI = URL + URN

 

반응형
반응형

jQuery - URL add Hash, get HashjQuery - URL add Hash, get Hash

var url = $(location).attr("href");

url.substring(url.indexOf('#'));

window.location="#222" 

반응형
반응형

JSP - 현재 페이지 경로,URL,URI,Path,Domain 추출

 

Context : <%= request.getContextPath() %>
URL : <%= request.getRequestURL() %>
URI : <%= request.getRequestURI() %>
Path : <%= request.getServletPath() %>
Domain : <%=request.getRequestURL().toString().replace(request.getRequestURI(),"") %>

 

 

 

반응형
반응형

url 가져오기, get url - javascript, jQuery

 

javascript

window.location;

window.location.replace('/','');

jQuery

$(location).attr('pathname');

$(location).attr('pathname').replace('/','');

반응형
반응형

[javascript] 현재 경로를 찾아서 어느 위치인지 인식한다.

 

 

   //-- 현재 url 호출
    var now_path_nm = location.pathname;

 

  //-- 현재 url에 찾고 있는 문자가 있으면 -1 보다 큰 숫자 리턴
    var result = now_path_nm.indexOf("s");

반응형

+ Recent posts