js变量怎样加入超链接,望高手指点 js变量怎样加入超链接,望高手指点js变量 怎么赋值到页面的超链接望高手指点 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title></head><body><a href="http://www.126.com/" id="demolink">无标题文档</a><button onclick="foo();">click</button><script type="text/javascript">var str="teststr";function foo(){ document.getElementById('demolink').href+='?teststr';}</script></body></html> <a href="#" id="link">待设置的超链接</a> document.getElementById('link').href = 'http://www.baidu.com'; <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title><script type="text/javascript">function btnClick() { var container = document.getElementById('container'); var aLink = document.createElement('a'); aLink.href = 'http://www.sina.com.cn'; var textNode = document.createTextNode('新浪'); aLink.appendChild(textNode); container.appendChild(aLink);}</script></head><body><input type="button" onclick="btnClick()"></input><div id="container"></div></body></html>这个?? 谢谢各位 高手 现在 我有个 变量 right 怎样 加入 到 比如 www.baidu.com?right 这样的连接而且用 document.getElementById('link').href = 'http://www.baidu.com';只能对 一个超链接有效 我需要对多个超链接有效 function setHref(right){ document.getElementById('link').href = 'http://www.baidu.com?right='+right;} 可以在这个函数里加多条语句,有几个link就加几条.. :) document.getElementById('link').href = 'http://www.baidu.com?'+right; <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=big5" /><title>Untitled Document</title></head><body> <a id="link">Baidu</a></body></html><script>document.getElementById("link").onclick=function(){setHref('','','_self','link');}function setHref(url,param,target,el){ if(url=='') url='http://www.baidu.com/?'; if(url.indexOf('?')<0){ url += '?'; } url += param; if(el==''){ return; } var obj = eval("document.getElementById('" + el + "')"); if(obj == null || typeof(obj)=='undefined') return; obj.target = target; obj.href = url;}</script> function link(id){ location.href = "login.php?id=" + id;} 菜鸟请教关于jquery tools的问题 省市级联动~~ 请大师指教 在JavaScript中是否可以调用ASP函数?还是不可以? 使用localeCompare按照汉字拼音排序的结果不太准怎么处理? MediaPlay 页面错误如何转向另外一个页面,关于音乐防盗链问题 菜鸟提问!在本机上有个bat文件会每天执行调用一个js新建一个以日期为文件名的文件夹,然后我在调用.......... 问个关于JS代码时机的问题 大家讨论讨论:有没有好的办法来保护自己的.js文件不被看见源码,更不能被下载的高招? jquery 一览数据过滤 紧急求助 css实现图片上传显示圆角效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<a href="http://www.126.com/" id="demolink">无标题文档</a>
<button onclick="foo();">click</button>
<script type="text/javascript">
var str="teststr";
function foo(){
document.getElementById('demolink').href+='?teststr';
}
</script>
</body>
</html>
<a href="#" id="link">待设置的超链接</a> document.getElementById('link').href = 'http://www.baidu.com';
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">function btnClick() {
var container = document.getElementById('container');
var aLink = document.createElement('a');
aLink.href = 'http://www.sina.com.cn';
var textNode = document.createTextNode('新浪');
aLink.appendChild(textNode);
container.appendChild(aLink);
}
</script>
</head>
<body>
<input type="button" onclick="btnClick()"></input>
<div id="container"></div>
</body>
</html>这个??
function setHref(right){
document.getElementById('link').href = 'http://www.baidu.com?right='+right;
}
可以在这个函数里加多条语句,有几个link就加几条..
:)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>Untitled Document</title>
</head><body>
<a id="link">Baidu</a>
</body>
</html>
<script>
document.getElementById("link").onclick=function(){setHref('','','_self','link');}
function setHref(url,param,target,el){
if(url=='') url='http://www.baidu.com/?';
if(url.indexOf('?')<0){
url += '?';
}
url += param;
if(el==''){
return;
}
var obj = eval("document.getElementById('" + el + "')"); if(obj == null || typeof(obj)=='undefined') return;
obj.target = target;
obj.href = url;
}
</script>
function link(id){
location.href = "login.php?id=" + id;
}