在xml中用javascript请教

netspy 2002-02-22 10:44:42
加精
为了pageOnload时调用某个page
我在和这个xml对应的xsl文件中用javascript:
<script>
<xsl:attribute name="src">../hit.aspx?filename=<xsl:value-of
select="FileName"/></xsl:attribute>
</script>
实现是实现到了,但浏览器老报错说语法错误,可以确定错在这几句。
请问为什么会错呢?
thx
...全文
53 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
netspy 2002-02-25
  • 打赏
  • 举报
回复
终于解决了,呵呵
xsl:
<script language="C#">
~~~~~~注意这里
<xsl:attribute name="src">../hit.aspx?filename=<xsl:value-of select="FileName"/></xsl:attribute>
</script>


hit.aspx:这里放一个空的script给src调用
<script language="C#"></script>
或者直接把代码写在<script language="C#"></script>之间也可以。

这样就没问题咯:)
谢谢karma的提示,给分:)
netspy 2002-02-23
  • 打赏
  • 举报
回复
hit.aspx是一个空页面,对应的.cs文件里只有一个类:
牛人帮忙看看

public class hit : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
conn.Open();
string sql = "update xmlBBS_subject set Click = Click + 1 where FileName = '" + Request["filename"].Split('.')[0] + "'";
SqlCommand cmd = new SqlCommand(sql,conn);
try
{
cmd.ExecuteNonQuery();
}
catch(System.Exception E)
{
Response.Write(E.Message);
}
finally
{
cmd.Dispose();
conn.Close();
}

}
netspy 2002-02-23
  • 打赏
  • 举报
回复
都试过了,还是不行。
纳闷阿!
karma 2002-02-23
  • 打赏
  • 举报
回复
remove the following two lines:
<script language="javascript">
</script>

or, try this, change your hit.aspx to only return this line
document.write("hello, world!");
karma 2002-02-23
  • 打赏
  • 举报
回复
look at the generated html file, find out the exact URL inside "src" attribute for
<script src="....."></script>

then enter the URL inside the address box in a browser, tell us what you get back
netspy 2002-02-23
  • 打赏
  • 举报
回复
兄台的意思是hit.aspx中必须包括有jscript function吗?
我加入了这么一段
<script language="javascript">
var s = "1231";
document.write(s);
function hello()
{
alert("hello");
}
</script>
但仍然有错,搞不明白的说:(
karma 2002-02-23
  • 打赏
  • 举报
回复
if what you just posted above is the content generated by hit.aspx, then no wonder you got scripting errors, since they are not valid javascript statements, for
<script src="whatever.aspx" language="javascript"></script>
to work, "whatever.aspx" must generate code like
var s = "1231";
document.write(s);
function hello()
{
alert("hello");
}
netspy 2002-02-23
  • 打赏
  • 举报
回复
这是html,其中并无<script>...
我该怎么做?help
<%@ Page language="c#" Codebehind="hit.aspx.cs" AutoEventWireup="false" Inherits="xmlbbs.hit" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>hit</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="hit" method="post" runat="server">
<FONT face="宋体"></FONT>
</form>
</body>
</HTML>
karma 2002-02-22
  • 打赏
  • 举报
回复
most likely, your aspx file did not create valid javascript statements, what does your hit.aspx file look like?

8,909

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧