我这边模拟写了一个function<script language="javascript" type="text/javascript"> function test() { var url = "www.sina.com"; var aaa = "aaa"; var bbb = "bbb"; var ccc = "ccc"; var str_content = "<li><a href='"+url+"kw="+ aaa +"' title=\""+bbb+"\">"+ccc+"</a></li>";
同意,我这么写的也没报错 var c = 'abcad'; var url="www.baidu.com?"var str_content ="<li><a href='"+url+"kw="+c+"' title=\""+c+"\">"+c+"</a> </li>"; alert(str_content)
function test()
{
var url = "www.sina.com";
var aaa = "aaa";
var bbb = "bbb";
var ccc = "ccc";
var str_content = "<li><a href='"+url+"kw="+ aaa +"' title=\""+bbb+"\">"+ccc+"</a></li>";
alert(str_content);
}
</script>打印出来的结果是:<li><a href='www.sina.comkw=aaa' title="bbb">ccc</a></li>
先不说这个href是不是少了?号,你是不是想href='www.sina.com?kw=aaa'
就算少了?号也不至于报 "不支持此属性或者方法"
检查你传的每一个参数,肯定是有参数没处理好。
同意,我这么写的也没报错
var c = 'abcad';
var url="www.baidu.com?"var str_content ="<li><a href='"+url+"kw="+c+"' title=\""+c+"\">"+c+"</a> </li>";
alert(str_content)
<head>
<title>Not Found</title>
<style>
body {font-family:"Verdana";font-weight:normal;font-size: 8pt;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Lucida Console";font-size: 8pt}
.er {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
</style>
</head>
<body bgcolor="white"> <span><h1>“/weixin”应用程序中的服务器错误。<hr width=100% size=1 color=silver></h1> <h2> <i>HTTP 错误 404 - Not Found。</i> </h2></span> <hr width=100% size=1 color=silver> <b>版本信息:</b> ASP.NET Development Server 9.0.0.0 </font> </body>
</html>
encodeURI(URIstring)
参数 描述
URIstring 必需。一个字符串,含有 URI 或其他要编码的文本。 返回值
URIstring 的副本,其中的某些字符将被十六进制的转义序列进行替换。实例
在本例zhogn,我们将使用 encodeURI() 对 URI 进行编码:<script type="text/javascript">document.write(encodeURI("http://www.w3school.com.cn")+ "<br />")
document.write(encodeURI("http://www.w3school.com.cn/My first/"))
document.write(encodeURI(",/?:@&=+$#"))</script>
输出:http://www.w3school.com.cn
http://www.w3school.com.cn/My%20first/
,/?:@&=+$#
<html>
<head>
<title>Not Found</title>
<style>
body {font-family:"Verdana";font-weight:normal;font-size: 8pt;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Lucida Console";font-size: 8pt}
.er {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
</style>
</head>
<body bgcolor="white"> <span><h1>“/weixin”应用程序中的服务器错误。<hr width=100% size=1 color=silver></h1> <h2> <i>HTTP 错误 404 - Not Found。</i> </h2></span> <hr width=100% size=1 color=silver> <b>版本信息:</b> ASP.NET Development Server 9.0.0.0 </font> </body>
</html>
能输出str_content看下么?确定路径是否正确.