views:

922

answers:

3

I have a simple HTML (as HTA) application that shows strange behavior on Windows XP x64 machine. I getting periodically (not every time) error message "Access is denied." when i start the application. The same application on Windows XP 32bit runs just fine...

Does somebody has any idea or explanation?

Error message: Line: 18 Char: 6 Error: Access is denied. Code: 0 URL: file:///D:/test_j.hta

Here is the code of my "test_j.hta":

<html>

<head>
<title>Test J</title>

<HTA:APPLICATION 
     ID="objTestJ" 
     APPLICATIONNAME="TestJ"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>

<script language="JScript">

function main()
{
     //window.alert("test");
     window.resizeTo(500, 300);        
}

function OnExit()
{
    window.close();
}

</script>

</head>

<body onload="main()">
     <input type="button" value="Exit" name="Exit" onClick="OnExit()" title="Exit">
</body>
</html>
+2  A: 

Try adding a try catch around the startup code

try
{ 
    window.resizeTo(500, 300); 
} catch(e) { }

Alternatively try setTimeout:-

setTimeout(function() {
    window.resizeTo(500, 300);
}, 100);
AnthonyWJones
Thanks! setTimeout() do the job!!!
mem64k
+1  A: 

Just a quick word for anyone who passes here I've run into a similar problem (mine is when the document is already loaded) and it is due to the browser not being ready to perform the resize/move actions whether it is due to not finishing loading or (like in my case) when it is still handling a previous resize request.

Ittai
+1  A: 

With both delay and try-catch:

setTimeout(function() {
    try { 
        window.resizeTo(500, 300); 
    } 
    catch(e) { }
}, 100);
Bill Paetzke