SSI with JavaScript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jane Withnolastname

    SSI with JavaScript

    How can I include a file using JavaScript?

    document.write( '<!--#include file="myfile.ht m" -->')

    won't work because of the commenting. Is there a way to fool
    JavaScript into including the file at the appropriate point?

    Currently I am calling iframes instead of using SSI. You can see why
    I'd want to switch.

    If it cannot be done with SSI, is there another inclusion format that
    will work?

    (For those who want to chastise me for using JavaScript at all, rest
    assured I am not abusing it and that the appropriate <noscript> tags
    are in use.)


  • Isofarro

    #2
    Re: SSI with JavaScript

    Jane Withnolastname wrote:
    [color=blue]
    > How can I include a file using JavaScript?
    >
    > document.write( '<!--#include file="myfile.ht m" -->')
    >
    > won't work because of the commenting. Is there a way to fool
    > JavaScript into including the file at the appropriate point?[/color]

    XmlHttpRequest
    [color=blue]
    > (For those who want to chastise me for using JavaScript at all, rest
    > assured I am not abusing it and that the appropriate <noscript> tags
    > are in use.)[/color]


    --
    Iso.
    FAQs: http://html-faq.com http://alt-html.org http://allmyfaqs.com/
    Recommended Hosting: http://www.affordablehost.com/
    Web Design Tutorial: http://www.sitepoint.com/article/1010

    Comment

    • Steve Pugh

      #3
      Re: SSI with JavaScript

      Jane Withnolastname <JaneWithnolast nameNOSPAM@yaho o.com> wrote:
      [color=blue]
      >How can I include a file using JavaScript?
      >
      >document.write ('<!--#include file="myfile.ht m" -->')
      >
      >won't work because of the commenting.[/color]

      Uh no. It won't work because JavaScript is handled by the browser and
      SSIs are handled by the server. So by the time the JavaScript is
      parsed it is far too late for the SSI to be parsed.

      It may help if you gave a bit more background. Why does this file need
      to be included by JavaScript, why can it not just be included once?

      Steve

      --
      "My theories appal you, my heresies outrage you,
      I never answer letters and you don't like my tie." - The Doctor

      Steve Pugh <steve@pugh.net > <http://steve.pugh.net/>

      Comment

      • Jane Withnolastname

        #4
        Re: SSI with JavaScript

        On Mon, 29 Sep 2003 10:05:18 +0100, Steve Pugh <steve@pugh.net > wrote:
        [color=blue]
        >Jane Withnolastname <JaneWithnolast nameNOSPAM@yaho o.com> wrote:
        >[color=green]
        >>How can I include a file using JavaScript?
        >>
        >>document.writ e('<!--#include file="myfile.ht m" -->')
        >>
        >>won't work because of the commenting.[/color]
        >
        >Uh no. It won't work because JavaScript is handled by the browser and
        >SSIs are handled by the server. So by the time the JavaScript is
        >parsed it is far too late for the SSI to be parsed.
        >
        >It may help if you gave a bit more background. Why does this file need
        >to be included by JavaScript, why can it not just be included once?
        >
        > Steve[/color]

        OK.
        When I list something on eBay, I add it to my web page. That's easy.
        But I don't want to have to be there and on the ball in order to take
        it off my web page when the auction ends. Therefore, I use a
        JavaScript to "expire" it at the proper time.
        If the auction is not over, the script shows the iFrame. If the
        auction is over, it reverts to just an eBay button (which is what
        noscript browsers see anyway).
        Ideally, I want to rid myself of iFrames, but without SSI, I cannot
        figure out how to get another page into my main page.
        Maybe I'm asking for the impossible. If that's the case, I guess I'm
        stuck with the iFrames - which I hate just as much as everyone else
        here!
        Thanks.

        Comment

        • Jane Withnolastname

          #5
          Re: SSI with JavaScript

          On Mon, 29 Sep 2003 09:32:01 +0000, Isofarro
          <spamblock@spam detector.co.uk> wrote:
          [color=blue]
          >Jane Withnolastname wrote:
          >[color=green]
          >> How can I include a file using JavaScript?
          >>
          >> document.write( '<!--#include file="myfile.ht m" -->')
          >>
          >> won't work because of the commenting. Is there a way to fool
          >> JavaScript into including the file at the appropriate point?[/color]
          >
          >XmlHttpReque st[/color]

          I'm sorry, I don't know what that means.
          Can you elaborate? Or point me in the direction of a tutorial that
          will further explain this or tell me how to implement it?
          Unless I'm missing something, this is XML, rather than HTML. Is it
          much different? Or can it be included in a HTML document?
          (I bet that made me look really stupid, but I have absolutely no
          experience with XML and, frankly, it scares me. But if it solves my
          problems, I will do it.)

          Comment

          • Mark Parnell

            #6
            Re: SSI with JavaScript

            Sometime around Thu, 02 Oct 2003 02:22:44 GMT, Jane Withnolastname is
            reported to have stated:[color=blue]
            > OK.
            > When I list something on eBay, I add it to my web page. That's easy.
            > But I don't want to have to be there and on the ball in order to take
            > it off my web page when the auction ends. Therefore, I use a
            > JavaScript to "expire" it at the proper time.[/color]

            That could be done fairly easily via SSI and some server-side scripting
            (PHP, ASP, etc).

            --
            Mark Parnell

            Comment

            • Isofarro

              #7
              Re: SSI with JavaScript

              Jane Withnolastname wrote:
              [color=blue]
              > On Mon, 29 Sep 2003 09:32:01 +0000, Isofarro
              > <spamblock@spam detector.co.uk> wrote:
              >[color=green]
              >>Jane Withnolastname wrote:
              >>[color=darkred]
              >>> How can I include a file using JavaScript?
              >>>
              >>> document.write( '<!--#include file="myfile.ht m" -->')
              >>>
              >>> won't work because of the commenting. Is there a way to fool
              >>> JavaScript into including the file at the appropriate point?[/color]
              >>
              >>XmlHttpReques t[/color]
              >
              > I'm sorry, I don't know what that means.
              > Can you elaborate?[/color]

              XmlHttpRequest is an object in both Internet Explorer 5+ browsers and
              Mozilla based browsers. It allows a page to request resources over HTTP.

              <http://jibbering.com/2002/4/httprequest.htm l>
              <http://www.15seconds.c om/issue/020606.htm>
              <http://www.xulplanet.c om/references/elemref/ref_XMLHttpRequ est.html>
              <http://www.scottandrew .com/weblog/2002_04#a000257 >
              <http://msdn.microsoft. com/library/default.asp?url =/library/en-us/xmlsdk30/htm/xmobjxmlhttpreq uest.asp>
              <http://msdn.microsoft. com/library/default.asp?url =/library/en-us/xmlsdk30/htm/xmobjpmexmlhttp request.asp>
              [color=blue]
              > Unless I'm missing something, this is XML, rather than HTML.[/color]

              It allows any sort of data to be transferred, not just XML.
              [color=blue]
              > Is it
              > much different? Or can it be included in a HTML document?[/color]

              Script using XmlHttpRequest functions is within the page, it requests an
              external resource - be it XML, HTML, plain text, whatever.

              Then just insert that into the document at the correct place using DOM
              techniques such as getElementById( ) and appendChild().

              DOM reference:
              <http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html>

              This is what I do here:


              Select an option from the drop down list, and click "Get Blog Entries", this
              fires off a request for an XML document and extracts a list of entries
              which dynamically populates the next page which is the "Entries from
              selected server:" page.

              [color=blue]
              > (I bet that made me look really stupid, but I have absolutely no
              > experience with XML and, frankly, it scares me. But if it solves my
              > problems, I will do it.)[/color]

              You don't need to use XML if you don't want to. As long as you send the data
              in a manner you can insert it in the right place, then the data can be of
              any format. I chose XML because that was the format the data I needed to
              work with was already in.


              --
              Iso.
              FAQs: http://html-faq.com http://alt-html.org http://allmyfaqs.com/
              Recommended Hosting: http://www.affordablehost.com/
              Web Design Tutorial: http://www.sitepoint.com/article/1010

              Comment

              Working...