【发布时间】:2018-05-22 09:11:53
【问题描述】:
我不知道标题是否合适(抱歉)。 首先,我必须告诉你,我是 javascript 的新手。
我想制作更改 URL 的 javascirpt 并在单击时重定向它(在书签栏上创建)。 这个想法是改变URL:
https://mail.google.com/mail/u/0/h/[12_random_aphanumeric]/?&th=[16_random_aphanumeric]&v=c&s=a
到
https://mail.google.com/mail/u/0/#all/[16_random_aphanumeric]
例如更改:
https://mail.google.com/mail/u/0/h/bv293r3qycgk/?&th=16032287bb796882&v=c&s=a
到
https://mail.google.com/mail/u/0/#all/16032287bb796882
所以我像这样使用“window.location.assign”:
javascript: window.location.assign(window.location.toString().replace('*?&th=', 'https://mail.google.com/mail/u/0/#all/')); window.location.assign(window.location.toString().replace('&v=c&s=a', ' '));
当然它不起作用。
我只是不知道如何在上面使用 [*] 通配符。
任何建议都将不胜感激。
【问题讨论】:
标签: javascript html url url-rewriting friendly-url