remove url parameters with javascript or jquery

前端 未结 10 2413
臣服心动
臣服心动 2020-12-25 10:15

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
<         


        
10条回答
  •  长发绾君心
    2020-12-25 10:45

    For example we have:

    example.com/list/search?q=Somethink
    

    And you need use variable url like this by window.location.href:

    example.com/list/edit
    

    From url:

    example.com/list/search?q=Somethink
    example.com/list/
    
    var url = (window.location.href);
        url = url.split('/search')[0];
        url = (url + '/edit');
    

    This is simple solution:-)

提交回复
热议问题