Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7871775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:00:32+00:00 2026-06-03T02:00:32+00:00

Is it possible to handle a parameter to a javascript function in XSLT where

  • 0

Is it possible to handle a parameter to a javascript function in XSLT where the script is between tags <script type=text/javascript>....</script>. If possible could someone give a example. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:00:35+00:00Added an answer on June 3, 2026 at 2:00 am

    I think you’re getting confused between the two things: XSLT is something that is used (in this case) to generate HTML/javascript – once that generated HTML/javascript is received by the browser then the javascript can be run. I’m unaware of any such concept of the XSLT “passing” a variable to a javascript function.

    My guess is you want something like this XSLT…

    <script type="text/javascript">
      var myVar = "<xsl:value-of select="XPATHVALUE"/>";
      <xsl:text disable-output-escaping="yes"><![CDATA[
        function myFunc(){
          alert(myVar);
        }
      ]]></xsl:text>
    </script>
    

    If you put the main “body” of the javascript within the xsl:text element, it means you won’t get caught out using reserved characters (such as < > etc).

    The generated HTML/javascript that is set to the browser would end up as something like this, meaning calling myFunc would display “hello world”…

    <script type="text/javascript">
      var myVar = "hello world";
        function myFunc(){
          alert(myVar);
        }
    </script>
    

    Update

    As MichaelKey has highlighted, the <xsl:text> element above is unnecessary. This should produce the same thing…

    <script type="text/javascript">
      var myVar = "<xsl:value-of select="XPATHVALUE"/>";
      <![CDATA[
        function myFunc(){
          alert(myVar);
        }
      ]]>
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a good way to handle all possible collisions between two
Is it possible in Javascript to pass a variable through the src parameter? ie.
Is it possible to handle this event in some way? What happens in terms
Is it possible to handle such events as: Ctrl + mouse left button click;
Is it possible to handle a mouseDown event in VB.Net (2008) regardless of the
For a website/ vpath, it's possible to handle the Application_Error event to catch errors
Possible Duplicate: Open/handle Word documents like SharePoint I´ve developed one website where it is
How does apache handle caching of certain files, and is it possible to explicitly
I'd like to make it as general as possible - e.g. handle as many
I have a general JavaScript question. I'll give you my scenario and then ask

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.