Javascript 通过<;将参数传递到url;a>;标记int-html
我在变量(Javascript 通过<;将参数传递到url;a>;标记int-html,javascript,html,Javascript,Html,我在变量(var lan=urlParam('language'))中有所选语言。 我想在“a”标记中的url中将此语言作为参数传递(不使用PHP),如下所示: <a href="http://hotelscombined.sitewish.gr/HotelNameSearch.aspx?languageCode=lan"> 但它不起作用 我在等你的回答。 非常感谢。如果我理解正确,您可以使用document.write打印链接并添加变量作为语言参数 <script t
var lan=urlParam('language')
)中有所选语言。
我想在“a
”标记中的url中将此语言作为参数传递(不使用PHP),如下所示:
<a href="http://hotelscombined.sitewish.gr/HotelNameSearch.aspx?languageCode=lan">
但它不起作用
我在等你的回答。
非常感谢。如果我理解正确,您可以使用document.write打印链接并添加变量作为语言参数
<script type="text/javascript">document.write("<a href=\"http://hotelscombined.sitewish.gr/HotelNameSearch.aspx?languageCode=" + lan + "\">link description</a>");</script>
document.write(“”);
您的url位于一个字符串中,因此它不会放入变量的值,而只放入字符串“lan”
给你的链接一个ID,这样你就可以用javascript修改它的url
<a id="foo" href="http://hotelscombined.sitewish.gr/HotelNameSearch.aspx">
您希望使用JavaScript动态地向页面上的每个链接添加一个新的GET参数。对吗?
document.getElementById('foo').setAttribute('href', 'http://hotelscombined.sitewish.gr/HotelNameSearch.aspx?languageCode=' + lan);