S
Sunny
Hi,
Can someone tell me, How to load the Body Html from a text file that
contains javascript.
to Manage my files I am creating an Index Page.
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body onUnload ="WriteCSVFile();">
<script type="text/javascript">
function openWindow(openLink)
{
var abc = openLink;
window.open(abc);
}
function openWindow2()
{
alert(textnode1.value);
var abc = '"' + textnode1.value + '"'
//window.open(eval(abc));
alert(document.body.innerHTML);
}
var textnode1;
var textnode2;
function addRow(content,morecontent)
{
if (!document.getElementsByTagName('mytable')) return;
var tbl = document.getElementById('mytable');
tabBody=document.getElementsByTagName("TBODY").item(0);
var lastRow = tbl.rows.length;
var iteration = lastRow;
//alert(iteration);
row=document.createElement("TR");
cell1 = document.createElement("TD");
cell2 = document.createElement("TD");
textnode1=document.createElement('input');
textnode1.type = 'text';
textnode1.name = 'txtRow' + iteration;
textnode1.id = 'txtRow' + iteration;
textnode1.size = 80;
var answer = prompt("Enter the URL for Map.","");
textnode1.value =answer;
textnode2=document.createElement('input');
textnode2.type = 'button';
textnode2.name = 'txtRowBut' + iteration;
textnode2.id = 'txtRowBut' + iteration;
textnode2.width = "100"
textnode2.value = "New Map"
cell1.appendChild(textnode1);
cell2.appendChild(textnode2);
row.appendChild(cell1);
row.appendChild(cell2);
tabBody.appendChild(row);
document.all.txtRowBut5.attachEvent("onclick", openWindow2)
}
function WriteCSVFile()
{
var ForWriting = 2
var TriStateFalse = 0
var fsObj = new ActiveXObject("Scripting.FileSystemObject")
var newFile = fsObj.OpenTextFile("c:\\abc.txt", ForWriting, true,
TriStateFalse)
newFile.WriteLine(document.body.innerHTML)
newFile.Close()
}
</script>
<div id="plan" style="overflow: auto; width: 780px; height: 780px">
<div id="DateBox">
<script type="text/javascript">
document.write('<b>' + Date());
</script>
</div>
<br/>
<br/>
<br/>
<br/><br/>
<table id='mytable' style="font-family:Arial,Helvetica,Sans Serif;font-
size:90%;color:#330066" cellpadding="3" border="2">
<H3><B><U>INDEX</U></B></H3>
<tbody>
<tr><td><input type="TEXT" name="testlabels" style="width:510px"
value=""></td>
<TD><INPUT TYPE="button" VALUE=""
onClick="openWindow(document.getElementById('testlabels').value);">
</td></tr>
<tr><td><input type="TEXT" name="testlabels1" style="width:510px"
value=""></td>
<TD><INPUT TYPE="button" VALUE=""
onClick="openWindow(document.getElementById('testlabels1').value);">
</td></tr>
<tr><td><input type="TEXT" name="testlabels2" style="width:510px"
value=""></td>
<TD><INPUT TYPE="button" VALUE=""
onClick="openWindow(document.getElementById('testlabels2').value);">
</td></tr>
<tr><td><input type="TEXT" name="testlabels3" style="width:510px"
value=""></td>
<TD><INPUT TYPE="button" VALUE=""
onClick="openWindow(document.getElementById('testlabels3').value);">
</td></tr>
</tbody>
</table>
</form>
<INPUT TYPE="button" VALUE="Add Map" onClick="addRow();return false;">
<br/>
</div>
</body>
</html>
*****************************************************************************************************
At the Body unload I am taking the Body InnerHtml & saving it in a
File. abc.txt. As I am adding the Links on the fly to the table, so I
need some place to save them. I want that when Next time, I open this
webpage, It should automatically, read all the script that I saved to
abc.txt file. Or Is there a better way to add the contents & save it.
Can someone tell me, How to load the Body Html from a text file that
contains javascript.
to Manage my files I am creating an Index Page.
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body onUnload ="WriteCSVFile();">
<script type="text/javascript">
function openWindow(openLink)
{
var abc = openLink;
window.open(abc);
}
function openWindow2()
{
alert(textnode1.value);
var abc = '"' + textnode1.value + '"'
//window.open(eval(abc));
alert(document.body.innerHTML);
}
var textnode1;
var textnode2;
function addRow(content,morecontent)
{
if (!document.getElementsByTagName('mytable')) return;
var tbl = document.getElementById('mytable');
tabBody=document.getElementsByTagName("TBODY").item(0);
var lastRow = tbl.rows.length;
var iteration = lastRow;
//alert(iteration);
row=document.createElement("TR");
cell1 = document.createElement("TD");
cell2 = document.createElement("TD");
textnode1=document.createElement('input');
textnode1.type = 'text';
textnode1.name = 'txtRow' + iteration;
textnode1.id = 'txtRow' + iteration;
textnode1.size = 80;
var answer = prompt("Enter the URL for Map.","");
textnode1.value =answer;
textnode2=document.createElement('input');
textnode2.type = 'button';
textnode2.name = 'txtRowBut' + iteration;
textnode2.id = 'txtRowBut' + iteration;
textnode2.width = "100"
textnode2.value = "New Map"
cell1.appendChild(textnode1);
cell2.appendChild(textnode2);
row.appendChild(cell1);
row.appendChild(cell2);
tabBody.appendChild(row);
document.all.txtRowBut5.attachEvent("onclick", openWindow2)
}
function WriteCSVFile()
{
var ForWriting = 2
var TriStateFalse = 0
var fsObj = new ActiveXObject("Scripting.FileSystemObject")
var newFile = fsObj.OpenTextFile("c:\\abc.txt", ForWriting, true,
TriStateFalse)
newFile.WriteLine(document.body.innerHTML)
newFile.Close()
}
</script>
<div id="plan" style="overflow: auto; width: 780px; height: 780px">
<div id="DateBox">
<script type="text/javascript">
document.write('<b>' + Date());
</script>
</div>
<br/>
<br/>
<br/>
<br/><br/>
<table id='mytable' style="font-family:Arial,Helvetica,Sans Serif;font-
size:90%;color:#330066" cellpadding="3" border="2">
<H3><B><U>INDEX</U></B></H3>
<tbody>
<tr><td><input type="TEXT" name="testlabels" style="width:510px"
value=""></td>
<TD><INPUT TYPE="button" VALUE=""
onClick="openWindow(document.getElementById('testlabels').value);">
</td></tr>
<tr><td><input type="TEXT" name="testlabels1" style="width:510px"
value=""></td>
<TD><INPUT TYPE="button" VALUE=""
onClick="openWindow(document.getElementById('testlabels1').value);">
</td></tr>
<tr><td><input type="TEXT" name="testlabels2" style="width:510px"
value=""></td>
<TD><INPUT TYPE="button" VALUE=""
onClick="openWindow(document.getElementById('testlabels2').value);">
</td></tr>
<tr><td><input type="TEXT" name="testlabels3" style="width:510px"
value=""></td>
<TD><INPUT TYPE="button" VALUE=""
onClick="openWindow(document.getElementById('testlabels3').value);">
</td></tr>
</tbody>
</table>
</form>
<INPUT TYPE="button" VALUE="Add Map" onClick="addRow();return false;">
<br/>
</div>
</body>
</html>
*****************************************************************************************************
At the Body unload I am taking the Body InnerHtml & saving it in a
File. abc.txt. As I am adding the Links on the fly to the table, so I
need some place to save them. I want that when Next time, I open this
webpage, It should automatically, read all the script that I saved to
abc.txt file. Or Is there a better way to add the contents & save it.