关于xsl中的js脚本问题。

precipitant 2004-11-21 04:34:08
我的xsl模板非常复杂,里面有很多需要js的。本来(.htm时)都挺好的,
我加入了xsl语言,改成xsl文件后,当用它格式化一个xml文件时,出错。
就连

if(a>b){alert("liu")}
都出错。说什么:缺少')'

真的不知道该如何解决。。。

高手指点。
...全文
216 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
precipitant 2004-11-24
  • 打赏
  • 举报
回复
我已经更改了JS,以避免这种情况的发生。谢谢!
孟大哥是高手,还有思归,我经常读你们的文章,很有深度,实用性也非常强
孟子E章 2004-11-24
  • 打赏
  • 举报
回复
<script language="javascript">
<![CDATA[]>
</script>
即可
precipitant 2004-11-24
  • 打赏
  • 举报
回复
up
precipitant 2004-11-23
  • 打赏
  • 举报
回复
up
precipitant 2004-11-22
  • 打赏
  • 举报
回复
用了46539492(#我思故我在#) 的方法,还出错,不过错误不同了:
这次提示的错误是:语法错误

<script language="javascript">
<xsl:comment>
<![CDATA[
var picN=-1
function first(){
picN=0
showPict();
}
function back(){
picN--
if(picN< 0) picN=0;
document.albumlist.albumtitle.selectedIndex=picN+2;
showPict();
}
function forw(){
picN++
if(picN > 0) picN=0
document.albumlist.albumtitle.selectedIndex=picN+2;
showPict();
}
function last(){
picN=sum_photo
showPict();
}
function showPict(){
switch (picN) {
case 0: CardCode="1099276339.jpg"; break;

}
document.cardpict.src="http://loveimg.163.com/myphotoes/78/50/yangming_8888/"+CardCode;
}
function showALBUM() {
if (document.albumlist.albumtitle.selectedIndex>=2){
picN = document.albumlist.albumtitle.selectedIndex-2;
showPict();
}
}
function openPict()
{
if (picN==-1) { document.albumlist.albumtitle.selectedIndex=2;showALBUM();}
switch (picN) {
case 0: CardCode="1099276339.jpg"; break;

}
srcIMG="http://loveimg.163.com/myphotoes/78/50/yangming_8888/"+CardCode;
var newWin=window.open(srcIMG,"myalbum","status=no,scrollbars=1,resizable=1,width=800,height=600");
}
]]>//</xsl:comment>
</script>


precipitant 2004-11-22
  • 打赏
  • 举报
回复
我实在数据库中读出数据,然后用StringBuilder生成一个xml串,(一个元素一个元素的构造的),在xml串中引用了这个xsl用于格式化。最后用Response.Write(stringbuilder.ToString());

这种情况 xsl中的js在那里执行。
precipitant 2004-11-22
  • 打赏
  • 举报
回复
下面的脚本,方里面就出错。就是有> 和 <的地方都出错
<script language="javascript">
var picN=-1
function first(){
picN=0
showPict();
}
function back(){
picN--
if(picN<0) picN=0;
document.albumlist.albumtitle.selectedIndex=picN+2;
showPict();
}
function forw(){
picN++
if(picN>0) picN=0
document.albumlist.albumtitle.selectedIndex=picN+2;
showPict();
}
function last(){
picN=sum_photo
showPict();
}
function showPict(){
switch (picN) {
case 0: CardCode="1099276339.jpg"; break;

}
document.cardpict.src="http://loveimg.163.com/myphotoes/78/50/yangming_8888/"+CardCode;
}
function showALBUM() {
if (document.albumlist.albumtitle.selectedIndex>=2){
picN = document.albumlist.albumtitle.selectedIndex-2;
showPict();
}
}
function openPict()
{
if (picN==-1) { document.albumlist.albumtitle.selectedIndex=2;showALBUM();}
switch (picN) {
case 0: CardCode="1099276339.jpg"; break;

}
srcIMG="http://loveimg.163.com/myphotoes/78/50/yangming_8888/"+CardCode;
var newWin=window.open(srcIMG,"myalbum","status=no,scrollbars=1,resizable=1,width=800,height=600");
}

</script>
learner01 2004-11-22
  • 打赏
  • 举报
回复
up!
孟子E章 2004-11-21
  • 打赏
  • 举报
回复
你可以把你的全部内容贴来
孟子E章 2004-11-21
  • 打赏
  • 举报
回复
你可以
<script>
<![CDATA[
if(a>b){alert("liu")}
]>
</script>

不过你要分清楚你的js文件在服务器端执行还是在客户端
46539492 2004-11-21
  • 打赏
  • 举报
回复
把javascript脚本放在xsl:comment和cdata里面,像下面那样
<SCRIPT LANGUAGE="javascript">
<xsl:comment><![CDATA[

function GetIEVersion()
{
try
{
if(!window.clientInformation)return false;
if(window.clientInformation.appName.toLowerCase()!="microsoft internet explorer")return false;
if(window.clientInformation.appVersion.toLowerCase().indexOf("msie")==-1)return false;
var a=window.clientInformation.appVersion.toLowerCase().split(";");
for(var i=0;i<a.length;i++)
{
a[i]=a[i].replace(" ","");
if(a[i].indexOf("msie")==0)
{
var version=a[i].substr(4,a[i].indexOf(".")-2);
return version;
}
}
}
catch(exception)
{
}
return false;
}

window.IEVersion=GetIEVersion();

if(parseInt(window.IEVersion)<6)document.write("<style>textarea.content { behavior:url('/Expert/xsl/tacontent.htc')}</style>");
function mailto1()
{
document.mailto.email.value='';
var tmpText=prompt('请输入您朋友的EMail:',document.mailto.email.value);
if(tmpText){
document.mailto.email.value = tmpText;
document.mailto.submit();
}
}

]]>//</xsl:comment>
</SCRIPT>

62,040

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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