trying to document.write() a SSI

Discussion in 'Javascript' started by Greg Brant, Jan 29, 2004.

  1. Greg Brant

    Greg Brant Guest

    my script is

    document.write("<!-- #include
    virtual\"http://www.where-ever.com/whatevere.html\" -->")

    but in the html (view source) i get

    ---------------------------------------------------
    <script language="Javascript" type="text/Javascript">
    document.write("\
    -----------------------------------------------------
    and thats the end of the document..

    i also have some more document.write()'s above this in the same script
    tag and these are not executed.. im guessing because it doesent get to
    the </script> tag??

    also im guessing that the reason its stopping is because its
    encountering the html comment sequence "<!--".

    so how do i write this safley?

    cheers

    Greg
    Greg Brant, Jan 29, 2004
    #1
    1. Advertising

  2. "Greg Brant" <> wrote in message
    news:...
    > my script is
    >
    > document.write("<!-- #include
    > virtual\"http://www.where-ever.com/whatevere.html\" -->")
    >
    > but in the html (view source) i get
    >
    > ---------------------------------------------------
    > <script language="Javascript" type="text/Javascript">
    > document.write("\
    > -----------------------------------------------------
    > and thats the end of the document..
    >
    > i also have some more document.write()'s above this in the same script
    > tag and these are not executed.. im guessing because it doesent get to
    > the </script> tag??
    >
    > also im guessing that the reason its stopping is because its
    > encountering the html comment sequence "<!--".


    It doesn't matter. Even if you got the script to work it wouldn't work. SSI
    is done server side. That is why it is called Server Side include.

    By the time your script gets to execute you are client side, no further
    access to the server.
    Richard Formby, Jan 29, 2004
    #2
    1. Advertising

  3. Greg Brant

    Greg Brant Guest

    any suggestions how can i do what im trying to achieve?

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Greg Brant, Jan 29, 2004
    #3
  4. "Greg Brant" <> wrote in message
    news:4018f7df$0$70307$...
    >
    >
    > any suggestions how can i do what im trying to achieve?


    What exactly are you trying to achieve?


    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!


    Hmmm.
    Richard Formby, Jan 29, 2004
    #4
  5. Greg Brant

    kaeli Guest

    In article <4018f7df$0$70307$>,
    enlightened us with...
    >
    >
    > any suggestions how can i do what im trying to achieve?
    >


    Assuming you're trying to include the content of one page within
    another...
    Use an IFRAME if you have no server-side language available (aside from
    SSI).
    If you have ASP or JSP, they can include pages in the output. I'm pretty
    sure Perl can, too.

    If you're trying to include pages only if some condition is true, and
    that condition is determined on the client, you'll need javascript and
    an IFRAME, as far as I know.

    I'm out of ideas after that. :)

    --
    --
    ~kaeli~
    If it's tourist season, why can't we shoot them?
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
    kaeli, Jan 29, 2004
    #5
  6. "kaeli" <> wrote in message
    news:...
    <snip>
    >Assuming you're trying to include the content of one page
    >within another...
    >Use an IFRAME if you have no server-side language available
    >(aside from SSI).
    >If you have ASP or JSP, they can include pages in the output.
    >I'm pretty sure Perl can, too.
    >
    >If you're trying to include pages only if some condition is
    >true, and that condition is determined on the client, you'll
    >need javascript and an IFRAME, as far as I know.


    The greater flexibility of server-side scripting aside, I can't see a
    difference between:-

    < some HTML >
    <script type="text/javascript">
    document.write("<!-- [SSI inserted HTML] -->");
    document.write("something else");
    </script>
    < some more HTML>

    - and:-

    < some HTML >
    <!-- [SSI inserted HTML] -->
    <script type="text/javascript">
    document.write("something else");
    </script>
    < some more HTML>

    - Except that the latter is not JavaScript dependent and avoids having
    to worry about the appropriateness of the characters within the include
    in the context of a JavaScript string.

    That is, if the point is to get the included HTML onto the page why not
    include it in the HTML?

    Richard.
    Richard Cornford, Jan 29, 2004
    #6
  7. Greg Brant

    kaeli Guest

    In article <bvb7dl$hlh$1$>,
    enlightened us with...
    >
    > The greater flexibility of server-side scripting aside, I can't see a
    > difference between:-
    >

    <snip>

    Me neither actually.
    It's early. :)

    >
    > That is, if the point is to get the included HTML onto the page why not
    > include it in the HTML?
    >


    I think the OP wanted the html included only if some condition were
    satisfied. It was unclear if the condition was decided on the client or
    on the server. Actually, the whole question was unclear. *heh*

    --
    --
    ~kaeli~
    A plateau is a high form of flattery.
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
    kaeli, Jan 29, 2004
    #7
  8. Greg Brant

    Greg Brant Guest

    sorry fo being unclear.

    The idea is that if a user has filled in a for then a page is included,
    that page will take a variable posted from the form as an argument..

    so.

    the page to be included needs to process the variables and then be
    included..

    but i see that (obviously) SSI is server side..

    I do have access to PHP so i am going to do it this way.. i was trying
    to do it without php as a collegue is not proficient with the language

    thanks for your response, somtimes the obvious is too obvious


    cheers

    Greg

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Greg Brant, Jan 29, 2004
    #8
  9. Greg Brant

    @SM Guest

    Greg Brant a ecrit :
    >
    > sorry fo being unclear.
    >
    > The idea is that if a user has filled in a for then a page is included,
    > that page will take a variable posted from the form as an argument..


    you certainly can do that with JavaScript.

    The form
    <html>
    <form action="js_read.html">
    Give your Name :
    <input type=text name="MyArgument">
    <input type=submit value="GO">
    </fomr></html>

    to reach a specific page

    js_read.html
    <html>
    <script type="text/javascript">
    this.location.escape();
    if(MyArgument!='') self.location='trucmuche/'+MyArgument+'.htm';
    </script>
    Sorry JavaScript error
    </html>

    to write in a page

    js_read.html
    <html>
    <script type="text/javascript">
    this.location.escape();
    function dc(txt) { document.write(txt);}
    if(MyArgument!='') trucmuche ='<h2>Hello '+MyArgument+'</h2>';
    else trucmuche ='';
    </script>
    <body>
    blabla
    <script type="text/javascript">
    dc(trucmuche);
    </script>
    re blah blah
    </body>
    </html>

    and/or use ssi same way


    --
    ******** (enlever/remove [OTER_MOI] du/from reply url) *******
    St├ęphane MORIAUX : mailto:
    Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
    http://perso.wanadoo.fr/stephane.moriaux/internet/
    **************************************************************
    @SM, Jan 30, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JJ

    Home-made SSI chips

    JJ, Sep 21, 2003, in forum: VHDL
    Replies:
    8
    Views:
    7,724
    james
    Sep 27, 2003
  2. Xanathos
    Replies:
    0
    Views:
    459
    Xanathos
    Feb 2, 2005
  3. JM
    Replies:
    3
    Views:
    2,177
    Chris Smith
    May 14, 2004
  4. jullag
    Replies:
    20
    Views:
    305
    Frances
    Sep 22, 2005
  5. Frank Peterson
    Replies:
    9
    Views:
    228
    David Mark
    Jun 28, 2009
Loading...

Share This Page