Grab File

We include our ‘core’ library, in the header


    <script src="../Include/Core.js" type="text/javascript"></script>
          

This uses our very simple Ajax Request function ssGrabFile. ssGrabFile takes in two parameters, the id of an element and the URL of a web page.


    function preparePage()
    {
      var anchors = document.getElementById("sidebar").getElementsByTagName("a");
      for (var aCount=0; aCount != anchors.length; aCount++)
      {
        ssAddEvent(anchors[aCount], "click", showToMain, false);
      }
    }

    function showToMain(e)
    {
      var el = ssExtractEl(e);
      ssGrabFile("main",el.href);
      return ssStopTheRest(e);
    }

    ssAddLoadEvent(preparePage);
          
  • It automatically appends a dummy querystring to the URL, to override any caching.

Exclamation Warning

  • It is only recommended that grabFile is used to replace the contents of a div or a span, it has been know to be problematic when replacing other types of elements.
  • You can use Firebug’s console to view the response given by the target page, allowing any errors in the target page to be debugged.