PassMark Logo
Home » Forum

Announcement

Collapse
No announcement yet.

Passing the QUERY_STRING to the SSI via Javascript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Passing the QUERY_STRING to the SSI via Javascript

    Hi All,

    OK, I have most of my problems worked out. I'm using the following SSI to put the search results on an SHTML page that is managed by a CMS:



    But I need to get the search parameters from the URL. So, I'm using javascript:

    <script language="javascript">
    function getURLParam(){
    var strReturn = "";
    var strHref = window.location.href;
    if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase() ;
    strReturn = strQueryString;
    //alert(strReturn);
    }
    return strReturn;
    }
    </script>


    I've checked strReturn and it is set to ?zoom_query=MySearchString, but I am getting a Failed to execute CGI : Win32 Error Code = 2 error

    If I take out the javascript and put the actual query string value into the SSI (just for a test):



    everything works, so, it something to do with the way the SSI / javascript is being executed.

    Any ideas?

    TIA
    Lee

  • #2
    Unfortunately, this will not work.

    Javascript is executed on the client-side. This means that the script runs within the user's web browser, after the web page has been downloaded from the server.

    The SSI is executed on the server-side. This means that the operation is executed before the page is downloaded off the server.

    So when your SSI command is executed, the Javascript required to form the #exec command will not run and it would be unable to retrieve the URL parameters.

    See my post on the other thread about my conclusion to this scenario:
    http://www.wrensoft.com/forum/viewtopic.php?p=3675#3675
    --Ray
    Wrensoft Web Software
    Sydney, Australia
    Zoom Search Engine

    Comment


    • #3
      Hi Ray,

      Thanks for the info. Searching around the web, I did find some of the same info:

      #exec cgi works fine, but...no parameters
      #include virtual just includes the exe (but the parameters are passed from the URL (LOL)

      So, onto ASP. I'm not an ASP person, so I have some simple questions:

      Can I use the ASP code on a SHTML page? If so, I assume I need to put something in the Head section to tell the server that it should execute the ASP code?

      TIA
      Lee

      Comment


      • #4
        To get ASP code to run within a .shtml file, you would have to change the Mapping configuration in IIS (under web site "Properties"->"Home directory"->"Configure"->"Mappings").

        This may not be ideal if you need to perform other SHTML specific commands not available in ASP. However "#include" and many standard SSI stuff is properly supported in the ASP engine.
        --Ray
        Wrensoft Web Software
        Sydney, Australia
        Zoom Search Engine

        Comment


        • #5
          Hi,

          OK, it's all good now. A bit of a kludge, but here's what works for me:

          1. Created an ASP page with the code from the FAQ page
          2. Added the following script to the head of my search page (/Search/index.shtml):

          <script language="JavaScript">
          function getURLParam(){
          var strReturn = "";
          var strHref = window.location.href;
          if ( strHref.indexOf("?") > -1 ){
          var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase() ;
          strReturn = 'http://10.75.47.80:8888/RNP/Search/srch.asp'+strQueryString;
          }
          return strReturn;
          }
          </script>

          3. Added an iframe to my search page:

          <iframe name="srchframe" id="srchframe" src="" frameborder="0" scrolling="yes" width="513" height="400"></iframe>

          4. Added the following script below the iframe:

          <script type="text/javascript">
          var srchurl=getURLParam();
          srchframe.location.href=srchurl;
          </script>

          5. In the Zoom configuration, set the Results Linking to Frame or Window: _top

          6. In the Zoom configuration, set the link back URL to the ASP page I created

          Works like a charm!

          Thanks for your help!!

          cheers
          Lee

          Comment

          Working...
          X