asp html javascript

来源:百度知道 编辑:UC知道 时间:2024/06/06 13:51:07
将生成随机数的javascript文件放在text文件中,用asp程序调用生成html文件。结果javascript文件中的代码在html不执行。

上源代码:
----------------------------
set about_file=server.createobject("scripting.filesystemobject")
pass_string="..\text\index_1.txt"
set open_top_file=server.createobject("scripting.filesystemobject")
set opentf=open_top_file.opentextfile(server.mappath(pass_string))
text_string=opentf.readall
set opentf=nothing
set open_top_file=nothing
web_string=web_string+text_string
以上是读出javascript代码
set about_file2=server.createobject("scripting.filesystemobject")
folders2=server.MapPath("../index")
if not about_file2.folderexists(folders2) then
about_file2.createfolder(folders2)
end if

pass_string2=".html"
file_path2=folders2&pass_string2
set create_txt_file2=about_file2.createtextfile(file_path2,true)
set open_top_file2=server.createobject(&quo

……
你的代码相当于
<td ... bakcground =="../image/
(注意折行了...)
<script >--这才是关键,td在这里闭合了

系统没有找到script标签的开始,怎么能执行呢?

明白你的意思,想用随机的图片做背景,为什么不直接通过asp生成一个随机数打出来呢?<%=n%>

<td width="614" height="246" align="right" valign="bottom" background="../image/
<script language="JavaScript">
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
};
function rand(number) {
return Math.ceil(rnd()*number);
};
document.write(rand(9));
</script>
_middle.gif">
改为
<script LANGUAGE="JavaScript">
var index = Math.floor(Math.random() * 11);
document.write("<td width=614 height=246 valign=bottom background="+ index +".gif>");
</script>