-2

我有一个具有 JavaScript 函数的 XSL 文件。我在调用 JavaScript 函数时遇到错误,我不明白出了什么问题。请帮忙。

这是JavaScript:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                              xmlns:msxsl="urn:schemas-microsoft-com:xslt">
    <xsl:import href="page_layout.xsl"/>
    <xsl:output method="html" indent="yes"/>

    <msxsl:script language="JScript">
        <![CDATA[
        function EnableSubmit() 
        {
        alert ("Hello there");
        }
    ]]>
    </msxsl:script>

这是调用函数的形式 -

< form action="NewUserNavigation" method="post" name="NewUserNavigationForm">
            < input name="eventName" type="hidden" value="NewUserNavigationEvent"/>
            < div class="sansIcon">
            < input type="checkbox" name="chk" onClick="EnableSubmit()">I accept< /input>
            < /div>
            < div class="buttonBarPage">
            < input name="Submit" class="primary" type="submit" value="Continue"/>
            < /div>
        < /form>

表单和 JavaScript 都是同一个 .xml 文件的一部分。

4

2 回答 2

1

You misunderstand the role and meaning of <msxsl:script>.

It allows javascript functions that it contains to be called during the transformation -- not before or after the transformation has been run.

You actually want the XSLT transformation that creates the form also to generate the javascript text as its result, so that its functions are accessible by the form.

于 2012-06-27T12:36:23.153 回答
0

这个对我有用

var sh = new ActiveXObject("WScript.Shell")
sh.Popup("hello")
于 2022-02-19T15:25:22.040 回答