[英]javascript passing variables via url
好吧,問題也許不正確,但我開槍了。
我的劇本:
<a href="javascript:var%20u=location.href;window.open('http://localhost/url='+u);void(o)" onclick="return false">OMG, testing</a>
實際上,沒有javascript網址的樣子如下:
http://localhost/url=google.com
在這里要添加以下內容: &format = txt
因此,正確的網址應為:
http://localhost/url=google.com&format=txt
這是你想要的嗎:
<a href="javascript:var%20u=location.href;window.open('http://localhost/url='+u+'&format=txt');void(o)" onclick="return false">OMG, testing</a>
只需使用+將其添加到鏈接中,除非我誤解了這個問題。
<a href="javascript:var%20u=location.href;window.open('http://localhost/url='+u+'&format='+txt);void(o)" onclick="return false">OMG, testing</a>
假定txt是一個變量,否則將其全部放在引號中。
這樣就可以了,您必須執行與本地主機相同的操作
<a href="javascript:var%20u=location.href;window.open('http://localhost/url='+u+'&format='+txt);void(o)" onclick="return false">OMG, testing</a>
像那樣 :
<a href="javascript:var%20u=location.href;window.open('http://localhost/url='+u + '&format=txt');void(o)" onclick="return false">OMG, testing</a>
您只需將文本添加到您的網址字符串中
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.