简体   繁体   中英

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

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>

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

对于通过这里的任何人来说,这只是一个简单的字眼,我遇到了类似的问题(我的是何时已加载文档),这是由于浏览器尚未准备好执行调整大小/移动操作的缘故,无论是否是由于完成加载或(如我的情况)完成加载,或者仍在处理先前的调整大小请求。

With both delay and try-catch:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM