Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 这是什么;“未知名称”;Internet Exlorer 6中的JSException?_Java_Javascript_Applet_Jsobject - Fatal编程技术网

Java 这是什么;“未知名称”;Internet Exlorer 6中的JSException?

Java 这是什么;“未知名称”;Internet Exlorer 6中的JSException?,java,javascript,applet,jsobject,Java,Javascript,Applet,Jsobject,我正在使用JSObject从小程序中调用Javascript函数 我的小程序的SSCCE: package ch.vrag.web; import java.applet.Applet; import java.security.AllPermission; import java.security.CodeSource; import java.security.PermissionCollection; import java.security.Permissions; import ja

我正在使用JSObject从小程序中调用Javascript函数

我的小程序的SSCCE:

package ch.vrag.web;

import java.applet.Applet;
import java.security.AllPermission;
import java.security.CodeSource;
import java.security.PermissionCollection;
import java.security.Permissions;
import java.security.Policy;

import netscape.javascript.JSObject;

public class Sscce extends Applet {

private static final long serialVersionUID = -5403444704039831864L;

public void init() {
    try {
        Policy.setPolicy(new Policy() {
            Permissions perms = new Permissions();

            public PermissionCollection getPermissions(CodeSource codesource) throws SecurityException {
                AllPermission grant = null;
                grant = new AllPermission();
                perms.add(grant);
                return perms;
            }

            public void refresh() {
                // Do nothing
            }
        });
    }
    catch (Exception e) {
    }

    JSObject window = JSObject.getWindow(this);

    JSObject phoneNums = (JSObject) window.eval("getWindowRectangle()");

    int x;
    int y;
    int width;
    int height;

    if (phoneNums.getSlot(0) instanceof Integer) {
        x = (Integer) phoneNums.getSlot(0);
        y = (Integer) phoneNums.getSlot(1);
        width = (Integer) phoneNums.getSlot(2);
        height = (Integer) phoneNums.getSlot(3);
    }
    else if (phoneNums.getSlot(0) instanceof Double) {
        x = ((Double) phoneNums.getSlot(0)).intValue();
        y = ((Double) phoneNums.getSlot(1)).intValue();
        width = ((Double) phoneNums.getSlot(2)).intValue();
        height = ((Double) phoneNums.getSlot(3)).intValue();
    }
    else {
        return;
    }

    System.out.println("x: " + x + " y: " + y + " width: " + width + " height: " + height);

};
}
我的HTML文件的SSCE:

 <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
        <script type="text/javascript">
        function getWindowRectangle(){

            var winX = (document.all)?window.screenLeft-2:window.screenX;
            var winY = (document.all)?window.screenTop-2:window.screenY;

            var winWidth = (document.all)?document.documentElement.offsetWidth+4:window.outerWidth;
            var winHeight = (document.all)?document.documentElement.offsetHeight+4:window.outerHeight;

            return([winX,winY,winWidth,winHeight]);
        }       
    </script>

    <title>SSCCE</title>
</head>
<body>
    this is an SSCCE
    <APPLET CODE="ch.vrag.web.Sscce.class" name="SSCCE" codebase="scripts" archive="Sscce.jar" width=0 height=0 MAYSCRIPT >
    </APPLET>
</body>

这个例外有什么好处?我做错了什么?

这与浏览器没有正确运行Javascript有关。确保IE6已修补到SV3版本,并且启用了Javascript以及可能的安全设置。

这与浏览器无法正确运行Javascript有关。确保IE6已修补到SV3版本,并且启用了Javascript以及可能的安全设置。

的底部是小字:

为了获得最佳结果,请不要在小程序的init()方法中使用LiveConnect JSObject

原因是,在这一点上通常是
null
。在applet
start()
方法中,我更成功地获得了对
JSObject
的引用


我想应该是这样。对返回的
对象执行一些调试,在调试器中对其进行检查,以检查其内容是否符合预期。

的底部是小字:

为了获得最佳结果,请不要在小程序的init()方法中使用LiveConnect JSObject

原因是,在这一点上通常是
null
。在applet
start()
方法中,我更成功地获得了对
JSObject
的引用



我想应该是这样。对返回的
对象执行一些调试,在调试器中检查它,以检查内容是否符合预期。

Internet Explorer 6似乎在
getSlot()
命令方面有问题,但我可以使用一种解决方法

使用此对象:
JSObject phoneNums=(JSObject)window.eval(“getWindowRectangle()”

我可以从phoneNumbs(
phoneNums.toString();
)中获取字符串。此字符串以以下形式给出我的返回值:

1号,2号,3号,4号

这样我就可以拆分字符串并得到所需的数字


这个故事的寓意是,Internet Exlorer 6不是当代的,不应该再使用了

Internet Explorer 6似乎在
getSlot()
命令方面有问题,但我可以使用一种解决方法

使用此对象:
JSObject phoneNums=(JSObject)window.eval(“getWindowRectangle()”

我可以从phoneNumbs(
phoneNums.toString();
)中获取字符串。此字符串以以下形式给出我的返回值:

1号,2号,3号,4号

这样我就可以拆分字符串并得到所需的数字



这个故事的寓意是,Internet Exlorer 6不是当代的,不应该再使用了

为了更快地获得更好的帮助,请发布一篇文章。那么您的公司支持7.1%的比例@不是我们公司支持它。。。我们的客户--是的,这很烦人…我希望您能进行+150%的成本调整以支持它,如果您的客户支持,您的公司也会支持它。:)我当然希望他们能看看自己的日志,看到这一点。1%的人使用该浏览器为了更快地获得更好的帮助,请发布一篇文章。那么您的公司支持7.1%的比例@不是我们公司支持它。。。我们的客户--是的,这很烦人…我希望您能进行+150%的成本调整以支持它,如果您的客户支持,您的公司也会支持它。:)我当然希望他们能看看自己的日志,看到这一点。1%的人使用该浏览器是Sv2。。。你认为可能是这样吗?@Neifen看到你需要在IE6上测试它,你需要所有能得到的帮助。IE6甚至可能不支持那些特定的Javascript函数。Javascript函数不是问题,问题是
getSlot
我想。。。但我不知道为什么是Sv2。。。你认为可能是这样吗?@Neifen看到你需要在IE6上测试它,你需要所有能得到的帮助。IE6甚至可能不支持那些特定的Javascript函数。Javascript函数不是问题,问题是
getSlot
我想。。。但我不知道为什么我会出错。我试图注释代码行以查看错误在哪里,但我没有再出现错误,当我在Applet中注释
getSlot()
命令时…嗯,这并不好。。。但是当我追踪属性
phoneNums
时,我得到了“123322135342”(虚构的数字),所以我想我可以拆分它,而不是做
getSlot()。我试图注释代码行以查看错误在哪里,但我没有再出现错误,当我在Applet中注释
getSlot()
命令时…嗯,这并不好。。。但是当我追踪属性
phoneNums
时,我得到了“123322135342”(虚构的数字),所以我想我可以拆分它,而不是制作
getSlot()
东西。。。
java.lang.Exception: netscape.javascript.JSException: Unknown Name
JSObject phoneNums = (JSObject) window.eval("getWindowRectangle()");