简体   繁体   English

将javascript值传递给html链接

[英]passing javascript value into html link

I assume this is just a beginners issue, I would like to add the value of my variable urlvar1 into a link. 我认为这只是一个初学者问题,我想将我的变量urlvar1的值添加到链接中。 However it looks like this is not working. 但是看起来这不起作用。

document.write('<iframe id="frame" src="http://www.xxx.xx?ATID="'+urlvar1+'" title="project" frameborder="no" border="0">Your browser does not seem to handle frames properly, but you can go directly to the survey <a href="http://www.xxx.xx?ATID="'+urlvar1+' ">here</a>')

You have an extra double-quote " in each href attribute. 你有一个额外的双引号"在每个href属性。

It currently reads like: 它目前的内容如下:

href="http://www.xxx.xx?ATID="string"

where it should read like: 它应该读作:

href="http://www.xxx.xx?ATID=string"

See below for the working string: 请参阅下面的工作字符串:

document.write('<iframe id="frame" src="http://www.xxx.xx?ATID='+urlvar1+'" title="project" frameborder="no" border="0">Your browser does not seem to handle frames properly, but you can go directly to the survey <a href="http://www.xxx.xx?ATID='+urlvar1+'">here</a>')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM