我对JavaScript并不是很聪明,所以如何添加到“w.location.href”?我尝试过搜索,但也难以制定正确的问题。
这是Chrome书签的一部分:
encodeURIComponent(w.location.href)
这将返回broswer地址字段中的有效网址,例如http://www.domain.com。但是我怎样才能添加它,所以结尾就像是“http://www.domain.com/?rcode=abc1234”?
我试过了:
encodeURIComponent(w.location.href + "?rcode=abc12345")
和
encodeURIComponent(w.location.href + ('?rcode=abc12345')
但是没有任何工作,或者,它会在添加的字符串中删除“=”。
-
好的,我在这里添加了EDITED“flipit”代码:
javascript:void((function(d,w,p,s,r,t,l)%7Bt%3D(w.screenTop%7C%7Cw.screenY)%2B50%3Bl%3D(w.screenX%7C%7Cw.screenLeft)%2B(w.innerWidth%7C%7Cd.documentElement.offsetWidth%7C%7C0)/2-s/2%3Bw.__flipboard%3Dw.open(%27https://share.flipboard.com/bookmarklet/popout%3Fv%3D2%26title%3D%27%2BencodeURIComponent(d.title)%2B%27%26url%3D%27%2BencodeURIComponent(w.location.href + "?rcode=wlb535")%2B%27%26t%3D%27%2Bp,%27__flipboard_flipit%27,%27width%3D%27%2Bs%2B%27,height%3D%27%2Br%2B%27,top%3D%27%2Bt%2B%27,left%3D%27%2Bl%2B%27,location%3Dyes,resizable%3Dyes,status%3Dno,scrollbars%3Dno,personalbar%3Dno,toolbar%3Dno,menubar%3Dno%27)%3Bs%3Dd.createElement(%27script%27)%3Bs.setAttribute(%27type%27,%27text/javascript%27)%3Bs.setAttribute(%27src%27,%27https://d2jsycj2ly2vqh.cloudfront.net/bookmarklet/js/popout-helper.min.js%3Ft%3D%27%2Bp)%3Bd.body.appendChild(s)%3BsetTimeout(function()%7Bw.__flipboard.focus()%7D,50)%3B%7D)(document,window,(new Date().getTime()),535,565))
答案 0 :(得分:0)
试试这个:
var url = window.location;
url = encodeURI(url + '?rcode=abc12345');
答案 1 :(得分:0)
如果要以编程方式更改位置,请使用:
window.location.href += encodeURIComponent('?rcode=abc12345');