javascript - 在 XSLT 中定义和调用 Javascript 函数
问题描述
我想在 XSL 文件中定义一个函数,并使用它来评估 XSL 中的页面属性。我将函数定义如下:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:jsutil="http://www.w3.org/1999/xhtml" xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:dt="urn:schemas-microsoft-com:datatypes">
<xsl:output method="html" encoding="utf-8" indent="no" />
<script type="text/javascript">
<![CDATA[
...
function replaceTokenUrlCustomerInfo(url) {
...
var server_url;
...
return server_url;
}
在我的 XSL 中,我以这种方式调用该函数:
...
<xsl:element name="iframe">
<xsl:attribute name="src">
javascript:replaceTokenUrlCustomerInfo('<xsl:value-of select="DESC_URL"/>');
</xsl:attribute>
但是没有调用该函数,在浏览器控制台中我看到错误
ReferenceError:replaceTokenUrlCustomerInfo 未定义
我做错了什么?谢谢 我还有一个问题:我可以通过 Javascript 函数设置 src 属性吗?我只有 onclick 属性的经验
解决方案
推荐阅读
- java - LEFT JOIN SUBQUERY 中的 Blaze-Persistence GROUP BY 与根查询中的 COALESCE
- javascript - vuejs:改变宽度每个循环基于 vuejs 中数组的 2 个变量
- python - Seaborn 在多次调用函数时保存相同的数字
- linux - Linux 找到 Bash/Bourne 文件,然后添加 .sh
- google-cloud-platform - 如何从云中执行的 Dataflow 管道中的 Google Drive 文件夹中读取数据?
- python - 将文件写入 Python 三
- android - 使用 uri i/o 错误上传多种类型的文件以解析数据库
- regression - 我的 mae 函数与 sklearn 的函数相差 10^-16 倍。为什么?
- google-apps-script - 我可以创建单元格 A1 包含 API 密钥的工作表,然后在其他工作表上的脚本中引用该值吗?
- vuetify.js - 针对特定屏幕尺寸隐藏的 Vuetify Vspacer