OzonesDeck - 26 Jun. 2004 - 03:46:
HTA filesave functions
Okay, I have been beating my head against this ALL DAY! And I cant figure it out. I have my HTA set up as a frameset, because I found that just using my root HTML frameset as an HTA (or as a frame Identified as APPLICATION=yes) will nuke all variables in the scripting. Unfortunately, any scripting in a root HTML file ID'd as APPLICATION=YES seems to get nuked too...
I am trying to do a simple filesave function:
function SaveFile(filename,filedata)
{
Drv="C:\\"
if (filename !="")
{
var fso=new ActiveXObject("Scripting.FileSystemObject");
var a=fso.CreateTextFile(Drv+filename+".JS",true);
a.WriteLine(filedata);
a.Close();
}
}
but I cannot seem to make it fire by command from another page in any way. The best I have been able to achive is by setting one of the framesets from the HTA root to an HTML with this function in it... the problem is I cant seem to reach it to fire it off from the other framesets.....
I need help!!!
Try this :
file: Master.hta
<html>
<head>
<script>
function DoSomething()
{
alert("Hello, this is the frameset!");
}
</script>
</head>
<frameset cols="*,*">
<frame id="frmOne" src="one.html" application="yes"/>
<frame id="frmTwo" src="two.html" application="yes"/>
</frameset>
</html>
-------------------------------------------------------------
file: One.html
<html>
<head>
<script>
function DoSomething()
{
alert("Hello, this is frame 1 speaking!");
}
</script>
</head>
<body>
<button onclick="DoSomething()">Do something from here</button>
<button onclick="window.parent.frames['frmTwo'].execScript('DoSomething()')">Do something from other frame</button>
<button onclick="window.parent.execScript('DoSomething()')">Do something from frameset</button>
</body>
</html>
-------------------------------------------------------------
file: Two.html
<html>
<head>
<script>
function DoSomething()
{
alert("Hello, this is frame 2 speaking!");
}
</script>
</head>
<body>
<button onclick="DoSomething()">Do something from here</button>
<button onclick="window.parent.frames['frmOne'].execScript('DoSomething()')">Do something from other frame</button>
<button onclick="window.parent.execScript('DoSomething()')">Do something from frameset</button>
</body>
</html>
It seems to work fine for me