Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: document.write

  1. #1
    New Coder
    Join Date
    Jan 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question document.write

    I want to put this script into an external file:

    <!--
    function showbuttons() {

    var agt = navigator.userAgent.toLowerCase();
    var IEMAC = ((agt.indexOf("msie") != -1) && agt.indexOf("mac")!=-1);
    var N6 = (agt.indexOf("netscape6") != -1 || (agt.indexOf("netscape/6") !=-1 ));

    if ( N6 ) {
    return "Netscape 6 is unable to support our detailed reports. Please upgrade to Nescape 7.<P>";
    }
    if ( IEMAC ) {
    return "<P>";
    }

    return "<P><FORM><INPUT TYPE='button' value='Calculate' Name='btnCallCalc' onClick='document.calculator.calculate()'><INPUT TYPE='button' value='View Report' Name='btnOpenNote' onClick='openNote()'></FORM>";
    }

    function openNote()
    {

    var agt=navigator.userAgent.toLowerCase();
    var is_aol = (agt.indexOf("aol") != -1);

    leftpos=0;
    if (screen) {
    leftpos=screen.width/2 - 300;
    }

    if (is_aol) {
    var s = " ";
    s=document.calculator.sJavaScriptReport('HTML');
    document.write(s);
    }
    else {
    var OpenWindow=window.open("","newwin","toolbar=yes,menubar=yes,location=no,directories=no,status=no,scr ollbars=yes,resizable=yes,copyhistory=no,width=600,height=380,left="+leftpos+",top=20");
    var s = " ";
    s=document.calculator.sJavaScriptReport('HTML');
    OpenWindow.document.write(s);
    OpenWindow.document.close();
    OpenWindow.focus();
    }
    }

    // -->


    I know you can use <SCRIPT>document.write(showbuttons())</SCRIPT> if the script is internal.

    How do you do the document.write for an external file? (I did not write the script - obviously)

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Quote Originally Posted by Design 46
    I know you can use <SCRIPT>document.write(showbuttons())</SCRIPT> if the script is internal.

    How do you do the document.write for an external file? (I did not write the script - obviously)
    You will call it the same way as when it is internal. Just make sure to not put HTML comments <!-- --> in the external script.

  • #3
    New Coder
    Join Date
    Jan 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm getting an applet error. I don't undertand why. I changed it back. Maybe the URL would help.

    http://www.mybiweeklymortgagepayment...alculator.html

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Is it allowed put HTML tags within the TEXT_FOR_REPORT param of the applet?

    <PARAM name="TEXT_FOR_REPORT" value="<HTML>
    <HEAD>
    <TITLE>Biweekly Payments for an Existing Mortgage</TITLE>
    ...
    </BODY>
    </HTML>

    ">

    If it is, then you need to HTML encode the content like this:

    <PARAM name="TEXT_FOR_REPORT" value="&lt;HTML&gt;&#13;&lt;HEAD&gt; ...">

    Use this tool I just created to encode HTML automatically.
    Code:
    <html>
    <head>
    <title>HTML Encoder</title>
    <style type="text/css">
    body, input {
     font: normal 10pt Verdana;
    }
    fieldset {
      padding: 5px;
    }
    
    .button {
      text-align: center;
      margin-top: 1em; 
      margin-bottom: 2em;
    }
    
    textarea {
      width: 100%;
    }
    </style>
    <script type="text/javascript">
      String.prototype.htmlEncode = function (html){
        return this.replace(/\&/g, "&amp;").replace(/\</g, "&lt;").replace(/\>/g, "&gt;").replace(/\"/g, "&quot;").replace(/\r/g, "&#10;").replace(/\n/g, "&#13;");
      }
    </script>
    </head>
    <body>
    <form>
    <h1>HTML Encoder</h1>
    <fieldset>
     <legend>HTML Input</legend>
     <textarea name="input" id="input" rows="12" cols="50"></textarea>
    </fieldset>
    <div class="button"> 
      <input type="button" value="Encode HTML" onclick="this.form.output.value = this.form.input.value.htmlEncode()" />
      <input type="reset" id="reset" />
    </div>
    <fieldset>
     <legend>Encoded HTML Output</legend>
     <textarea name="output" id="output" rows="12" cols="50" readonly="readonly"></textarea>
    </fieldset>
    <div class="button"> 
      <input type="button" value="Select Text" onclick="this.form.output.select()" />
    </div>
    </form>
    </body>
    </html>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •