View Full Version : document.write

Design 46
01-18-2005, 05:55 AM
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);

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

if (is_aol) {
var s = " ";
else {
var OpenWindow=window.open("","newwin","toolbar=yes,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistor y=no,width=600,height=380,left="+leftpos+",top=20");
var s = " ";

// -->

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)

01-18-2005, 06:47 AM
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.

Design 46
01-18-2005, 08:08 PM
I'm getting an applet error. I don't undertand why. I changed it back. Maybe the URL would help.


01-19-2005, 02:50 AM
Is it allowed put HTML tags within the TEXT_FOR_REPORT param of the applet?

<TITLE>Biweekly Payments for an Existing Mortgage</TITLE>

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

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

Use this tool I just created to encode HTML automatically.

<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%;
<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, " ").replace(/\n/g, " ");
<h1>HTML Encoder</h1>
<legend>HTML Input</legend>
<textarea name="input" id="input" rows="12" cols="50"></textarea>
<div class="button">
<input type="button" value="Encode HTML" onclick="this.form.output.value = this.form.input.value.htmlEncode()" />
<input type="reset" id="reset" />
<legend>Encoded HTML Output</legend>
<textarea name="output" id="output" rows="12" cols="50" readonly="readonly"></textarea>
<div class="button">
<input type="button" value="Select Text" onclick="this.form.output.select()" />