【问题标题】:XSL OnChange Javascript Function not DefinedXSL OnChange Javascript 函数未定义
【发布时间】:2013-08-19 01:53:10
【问题描述】:

如果我从下拉菜单中选择任何内容,则不会调用 javascript 函数 showLeague 并引发错误:Uncaught ReferenceError: showLeague is not defined

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output
    method="html"
    omit-xml-declaration="yes"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    indent="yes"></xsl:output>
<xsl:param name="tsid" /> 


<xsl:template match="spocosy">      

    <form>
    Select a League:

    <select>
    <xsl:attribute name="name">
        <xsl:value-of select="cds"/>
    </xsl:attribute>

    <xsl:attribute name="onchange">
        showLeague(this.value)
    </xsl:attribute>


    <option value="">Leagues:</option>
    <xsl:for-each select="standing">
    <option>
    <xsl:attribute name="value">
        <xsl:value-of select="@id"/>
    </xsl:attribute>
    <xsl:value-of select="@league"/>
    </option>
    </xsl:for-each>  
    </select>
    </form>

    <div id="txtHint"><b>League info will be listed here...</b></div>
</xsl:template>

showLeague 函数在 head 标签中定义,没有 xsl 它可以正常工作。任何帮助,将不胜感激。如果你想观察 html 输出,这里是 url:http://tipslator.com/Table/deneme/

【问题讨论】:

  • 考虑发布一个最小但完整的示例,以便我们重现问题。
  • 我应该发布有关此问题的完整代码吗?
  • 尝试将问题隔离为最小但完整的示例,然后发布。或者发布一个我们可以访问问题的 URL。
  • @MartinHonnen 我希望我理解你的意思,我粘贴了整个 xsl 代码和 url,这样你就可以找到关于这个问题的所有信息。
  • 该页面中有一个 iframe 似乎是 XSLT 的结果,该 iframe 没有定义任何脚本函数,您为什么希望该函数可用?

标签: javascript xslt onchange


【解决方案1】:

文档 http://tipslator.com/Table/deneme/ 包含一个 iframe http://tipslator.com/xsl/getleaguename.php 和一个似乎是 XSLT 结果的 HTML 文档。该 iframe 文档根本没有定义任何脚本函数,因此对函数的任何调用都会出错,除非您确保在 iframe 中定义了这些函数(或者您调用 parent.functionName 来调用父窗口中定义的函数) .

【讨论】:

    猜你喜欢
    • 2012-09-19
    • 1970-01-01
    • 2023-04-05
    • 2016-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-21
    • 2017-06-06
    相关资源
    最近更新 更多