3 Replies Latest reply: Aug 28, 2012 7:40 AM by 746458 RSS

    Passing javascript variable to idoc script

    948916
      Hi,
      I want to pass my javascipt variable value to idoc script.
      Below is my hcsp file where is get the OS version using javascript and save it to WinVer variable.
      Now acc. to the WinVer value need to use if loop.

      Code Snippet:

      *<script type="text/javascript">*
      *     *
      *     var WinVer="Unknown OS";*
      *     *
      *     if (navigator.appVersion.indexOf("Windows NT 5.1")!=-1) WinVer="XP";*
      *     *
      *     if (navigator.appVersion.indexOf("Windows NT 6.1")!=-1) WinVer="Win7";*

      *</script>*

      *<!--$if strEquals(WinVer,"Win7")-->*
      *     test*
      *<!--$elseif strEquals(WinVer,"XP")-->     *
      *test1*
      *<!--$else-->*
      *     test2*
      *<!--$endif-->*
        • 1. Re: Passing javascript variable to idoc script
          Jonathan Hult
          Idoc Script is executed server side before the page is rendered. Thus, you cannot pass JavaScript (client side) variables to Idoc Script.

          Jonathan
          http://jonathanhult.com
          • 2. Re: Passing javascript variable to idoc script
            VikrantKorde 1
            IDOC script is a server side script and Java script is a client side script.
            The normal flow of execution is first service side script (IDOC) gets executed and then client side script (Java Script) is executed.
            So by the time Java script starts its execution, IDOC is complete and is out of bound.

            So in the same request we can not pass value of java script variable to IDOC. However you can create a new request and sent the value to IDOC but in that case the page will get refreshed.

            The basic question, why do you want to do this? What is the business case scenario?

            Regards,
            Vikrant Korde.
            • 3. Re: Passing javascript variable to idoc script
              746458
              Just guessing at what you are trying to do...

              Are you aware there is already an IDOC HTTP_USER_AGENT variable?

              Try adding the tag

              <!--$HTTP_USER_AGENT--> to an hcsp page and see what you get.

              Why don't you see if you can use that server side.


              Hope that helps
              Tim