Reprocess page after document.write

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Thompson

    #1

    Reprocess page after document.write

    I am working with a special tool which pre-processes the page. Using
    document.write, I am composing the page while it is loading, so I need
    to force a reprocess of the page AFTER the page loads.

    Is there some way to do that? That is, I want the browser to
    essentially act as if the composed page was the original page.


    Here is a brief version of the page construction technique:

    <!DOCTYPE HTML SYSTEM "-//W3C//DTD XHTML 1.0 Strict//EN">
    <HTML><HEAD>
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <SCRIPT LANGUAGE="JavaS cript" TYPE="text/javascript"><SC RIPT
    LANGUAGE="JavaS cript" TYPE="text/javascript">
    nxitm=" ";iam=" ";setstart=1;co mx=0;holdshf=fa lse;zmaxv=0;
    function oneitem(curp,ch kVls,chkNms) {
    alert('curp:'+c urp+',name:'+ch kNms[curp+11]+",val:"+chk Vls[curp+11]);
    var cma=0;var cmb=0;var retstr=' ';
    if (chkVls[curp+11] == 1) {
    if (chkVls[curp] == 1) {cma=1;}
    if (chkVls[curp+5] == 1) {cmb=1;}
    retstr='{sq'+'l } INSERT into shal';
    retstr=retstr=' tpkd.cmfform(pw =haltpwd) {\s'+'ql}';
    }
    return (retstr);
    }
    // get document.locati on, decode, assign
    var chkStr = document.locati on.href.split(' ?')[1].split('&');
    var chkNms = document.locati on.href.split(' ?')[1].split('&');
    var chkVls = document.locati on.href.split(' ?')[1].split('&');
    for(var x=0; x<chkStr.length ; x++)
    {
    var tmp = chkStr[x].split('=');
    chkNms[x]=unescape(tmp[0]);
    chkVls[x]=unescape(tmp[1]);
    eval(unescape(t mp[0]) + '="' + unescape(tmp[1]) + '"');
    }
    var restpage='<!DOC TYPE HTML SYSTEM "-//W3C//DTD XHTML 1.0 ';
    restpage=restpa ge+'Strict//EN">';
    restpage=restpa ge+'<HTML><HEAD ><TITLE>Concomi tant ';
    restpage=restpa ge+'Medications Form</TITLE>';
    restpage=restpa ge+'<SCRIPT LANGUAGE="JavaS cript"';
    restpage=restpa ge+' TYPE="text/javascript"';
    restpage=restpa ge+' SRC="http://localhost/haltpkd/java/mainjava.js">';
    restpage=restpa ge+'</SC'+'RIPT>';
    restpage=restpa ge+'<L'+'INK REL=STYLESHEET type="text/css"';
    restpage=restpa ge+' HREF="http://localhost/haltpkd/css/maincss.css">';
    restpage=restpa ge+'</L'+'INK>';
    restpage=restpa ge+'</H'+'EAD>';
    restpage=restpa ge+'<BO'+'DY>';
    restpage=restpa ge+'<FO'+'RM NAME="cmfform" METHOD="POST">' ;
    restpage=restpa ge+'{up'+'date server="rook:ha ltpkd" sapw="milo99ha" }';
    restpage=restpa ge+'{lib'+'rary sqlname="shaltp kd"';
    restpage=restpa ge+'path="/data/pkdtn/linux"}';
    restpage=restpa ge+'<INPUT TYPE="HIDDEN" NAME="_haltid"' ;
    restpage=restpa ge+' VALUE="'+chkVls[0]+'">';
    for (curp=13;curp<c hkVls.length-12;curp=curp+14 ) {
    restpage=restpa ge+oneitem(curp ,chkVls,chkNms) ;
    }
    restpage=restpa ge+'{/upd'+'ate}';
    restpage=restpa ge+'<SCRIPT LANGUAGE="JavaS cript"';
    restpage=restpa ge+' TYPE="text/javascript">';
    restpage=restpa ge+'document.cm fform.action=ac tstr+"getv.hsql ";';
    restpage=restpa ge+'document.cm fform.submit(); ';
    restpage=restpa ge+'</SC'+'RIPT> </F'+'ORM> </B'+'ODY> </H'+'TML>';
    </SCRIPT>
    </HEAD>
    <BODY>
    <FORM NAME="cmfform" METHOD="POST">
    <SCRIPT LANGUAGE="JavaS cript" TYPE="text/javascript">
    document.write( restpage);
    </SCRIPT>
    </BODY> </HTML>
  • Erwin Moller

    #2
    Re: Reprocess page after document.write

    Paul Thompson wrote:

    [color=blue]
    > I am working with a special tool which pre-processes the page. Using
    > document.write, I am composing the page while it is loading, so I need
    > to force a reprocess of the page AFTER the page loads.
    >
    > Is there some way to do that? That is, I want the browser to
    > essentially act as if the composed page was the original page.
    >[/color]

    Hi Paul,

    A suggestions that comes into mind (without any knowledge of all the
    difficulties your are in):
    Why not buffer the complete output in a var, and when done, write that?

    Regards,
    Erwin Moller

    Comment

    • Robert

      #3
      Re: Reprocess page after document.write

      In article <ctm27b$cdj$1@n ewsreader.wustl .edu>,
      Paul Thompson <paul@wubios.wu stl.edu> wrote:
      [color=blue]
      > I am working with a special tool which pre-processes the page. Using
      > document.write, I am composing the page while it is loading, so I need
      > to force a reprocess of the page AFTER the page loads.
      >
      > Is there some way to do that? That is, I want the browser to
      > essentially act as if the composed page was the original page.[/color]

      What is failing?

      You only need to escape the </script> tag. An easier way to do this is:
      <\/script>. When a browser sees, <script> it scans for the </script>
      tags. Some browser ignore things in quotes in when doing this scan.
      Hence the need for escaping.


      See RobG's explains how to construct a string containing html. Grooge
      won't let me point to one post but only a thred. Here is the thread:


      read/f8d72fff92b97c7 6/ddd4888398a775c 1?q=robg+Cant+c orrectly+load+. js&_do
      ne=%2Fgroup%2Fc omp.lang.javasc ript%2Fsearch%3 Fgroup%3Dcomp.l ang.javascrip
      t%26q%3Drobg+Ca nt+correctly+lo ad+.js%26qt_g%3 D1%26searchnow% 3DSearch+this
      +group%26&_done Title=Back+to+S earch&&d#ddd488 8398a775c1

      RobG Oct 14 2004, 8:17 pm
      Subject: Re: Cant correctly load .js files when creating page
      dynamically in IE

      Here is RobG's code. Hope he doesn't mind.

      <html>
      <head>
      <title>New Page</title>
      <script type="text/javascript">
      function loadWindow() {
      var VE3DWindow = window.open('',
      'VE3DWin','resi zable=1,width=4 00,height=400')
      var a = [
      '<!DOCTYPE HTML PUBLIC ',
      '"-//W3C//DTD HTML 4.01 Transitional//EN"',
      '"http://www.w3.org/TR/html4/loose.dtd">',
      '<html>',
      '<head>',
      '<meta http-equiv="Content-Type" ',
      'content="text/html; charset=iso-8859-1">',
      '<title>Untitle d Document</title>',
      '<script type="text/JavaScript" src="xx.js"></scr',
      'ipt>',
      '<script type="text/JavaScript">ale rt(location);</scr',
      'ipt>',
      '</head>',
      '<body>',
      '<p>Here is a page</p><p>here is some text</p>',
      '<p>and some more text</p>',
      '<form action=""><inpu t type="button" ',
      'value="Open Window"',
      'onclick="xx(); "></form>',
      '</body>',
      '</html>',
      ];
      VE3DWindow.docu ment.write(a.jo in(""))
      VE3DWindow.docu ment.close()
      }

      </script>
      </head>
      <body>
      <form action="">
      <input type="button" value="Open Window"
      onclick="loadWi ndow();">
      </form>
      </body>
      </html>

      file xx.js:

      function xx() {
      alert('hi');
      }


      Robert

      Comment

      • Robert

        #4
        Re: Reprocess page after document.write

        In article <ctm27b$cdj$1@n ewsreader.wustl .edu>,
        Paul Thompson <paul@wubios.wu stl.edu> wrote:
        [color=blue]
        > I am working with a special tool which pre-processes the page. Using
        > document.write, I am composing the page while it is loading, so I need
        > to force a reprocess of the page AFTER the page loads.[/color]

        There are a lot of bugs in the posted code. Try running the code in
        Firefox and look at the javascript console. I made some changes but
        after the first 7 errors I have stopped. The first error was a missing
        </script> tag on the first script line.

        the line:
        restpage=restpa ge+'Strict//EN">';
        can be written as:
        restpage += 'Strict//EN">';

        <!DOCTYPE HTML SYSTEM "-//W3C//DTD XHTML 1.0 Strict//EN">
        <HTML><HEAD>
        <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
        <SCRIPT LANGUAGE="JavaS cript" TYPE="text/javascript"></SCRIPT>
        <script LANGUAGE="JavaS cript" TYPE="text/javascript">
        nxitm=" ";iam=" ";setstart=1;co mx=0;holdshf=fa lse;zmaxv=0;
        function oneitem(curp,ch kVls,chkNms) {
        alert('curp:'+c urp+',name:'+ch kNms[curp+11]+",val:"+chk Vls[curp+11]);
        var cma=0;var cmb=0;var retstr=' ';
        if (chkVls[curp+11] == 1) {
        if (chkVls[curp] == 1) {cma=1;}
        if (chkVls[curp+5] == 1) {cmb=1;}
        retstr='{sq'+'l } INSERT into shal';
        retstr=retstr=' tpkd.cmfform(pw =haltpwd) {\s'+'ql}';
        }
        return (retstr);
        }
        // get document.locati on, decode, assign
        /*
        var chkStr = document.locati on.href.split(' ?')[1].split('&');
        var chkNms = document.locati on.href.split(' ?')[1].split('&');
        var chkVls = document.locati on.href.split(' ?')[1].split('&');
        for(var x=0; x<chkStr.length ; x++)
        {
        var tmp = chkStr[x].split('=');
        chkNms[x]=unescape(tmp[0]);
        chkVls[x]=unescape(tmp[1]);
        eval(unescape(t mp[0]) + '="' + unescape(tmp[1]) + '"');
        }
        actstr = " ";
        var restpage='<!DOC TYPE HTML SYSTEM "-//W3C//DTD XHTML 1.0 ';
        restpage=restpa ge+'Strict//EN">';
        restpage=restpa ge+'<HTML><HEAD ><TITLE>Concomi tant ';
        restpage=restpa ge+'Medications Form</TITLE>';
        restpage=restpa ge+'<SCRIPT LANGUAGE="JavaS cript"';
        restpage=restpa ge+' TYPE="text/javascript"';
        restpage=restpa ge+' SRC="http://localhost/haltpkd/java/mainjava.js">';
        restpage=restpa ge+'</SC'+'RIPT>';
        restpage=restpa ge+'<L'+'INK REL=STYLESHEET type="text/css"';
        restpage=restpa ge+' HREF="http://localhost/haltpkd/css/maincss.css">';
        restpage=restpa ge+'</L'+'INK>';
        restpage=restpa ge+'</H'+'EAD>';
        restpage=restpa ge+'<BO'+'DY>';
        restpage=restpa ge+'<FO'+'RM NAME="cmfform" METHOD="POST">' ;
        restpage=restpa ge+'{up'+'date server="rook:ha ltpkd" sapw="milo99ha" }';
        restpage=restpa ge+'{lib'+'rary sqlname="shaltp kd"';
        restpage=restpa ge+'path="/data/pkdtn/linux"}';
        restpage=restpa ge+'<INPUT TYPE="HIDDEN" NAME="_haltid"' ;
        restpage=restpa ge+' VALUE="'+chkVls[0]+'">';
        for (curp=13;curp<c hkVls.length-12;curp=curp+14 ) {
        restpage=restpa ge+oneitem(curp ,chkVls,chkNms) ;
        }
        restpage=restpa ge+'{/upd'+'ate}';
        restpage=restpa ge+'<SCRIPT LANGUAGE="JavaS cript"';
        restpage=restpa ge+' TYPE="text/javascript">';
        restpage=restpa ge+'document.cm fform.action=ac tstr+"getv.hsql ";';
        restpage=restpa ge+'document.cm fform.submit(); ';
        restpage=restpa ge+'</SC'+'RIPT> </F'+'ORM> </B'+'ODY> </H'+'TML>';
        </SCRIPT>
        </HEAD>
        <BODY>
        <FORM NAME="cmfform" METHOD="POST">
        <SCRIPT LANGUAGE="JavaS cript" TYPE="text/javascript">
        document.write( restpage);
        </SCRIPT>
        </BODY> </HTML>

        Comment

        Working...