Passing a URL as a GET parameter in Javascript

前端 未结 5 706
半阙折子戏
半阙折子戏 2021-01-04 10:07

I am trying to make a bookmarklet that uses the user\'s current URL, kind of like the tinyURL bookmarklet that uses this javascript code

javascript:void(loca         


        
5条回答
  •  离开以前
    2021-01-04 10:56

    javascript:void(location.href='http://mywebsite.com/create.php?url='+encodeURIComponent(location.href))
    

    You need to escape the characters.

提交回复
热议问题