“Access is denied” by executing .hta file with JScript on Windows XP x64

最后都变了- 提交于 2019-12-13 16:26:41

问题


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>

回答1:


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);



回答2:


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.




回答3:


With both delay and try-catch:

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


来源:https://stackoverflow.com/questions/464679/access-is-denied-by-executing-hta-file-with-jscript-on-windows-xp-x64

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!