当我更改 GWT 应用程序的 html 文件中的 document.domain 属性时,出现空白页

发布于 2024-10-19 15:32:20 字数 2174 浏览 4 评论 0原文

您好,我正在开发一个内部有 iframe 的 GWT 应用程序。我在本地主机中使用 Tomcat 6 和 IE8 进行测试。

我将 localhost 域(在主机文件中:C:\WINDOWS\system32\drivers\etc\hosts)更改为 Something1.something2.com,所以现在我的主机文件中有:

127.0.0.1something1.something2.com

因此,我在 IE8 Something1.something2.com:8080/mygwtapp 中运行 Tomcat6,并且 mygwtapp 运行正常。 问题是当我将 GWT 应用程序的 document.domain 更改为 file.html 时。 在 gui.html 中,我有这个:

<html>
    <head>
        <title>...</title>
        <style>...</style>
        <script language="javascript">
            document.write(document.domain);    
            document.domain = "something2.com"
            document.write(document.domain);
        </script>
        <meta name='gwt:module' content='scripts/com.something2.gui=com.something2.gui'>
    </head>
    <body>
        <script language="javascript" src="scripts/gwt.js"></script>
        <iframe id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe>
        <table align=center>
            <tr>
                <td id="slot1"></td>
                <td id="slot2"></td>
            </tr>
        </table>

    </body>
</html>

所以,我用这个 gui.html 再次运行我的应用程序,我得到:

something1.something2.comsomething2.com

(就像顶部的那样)这是预期的,但我得到的只是一个空白页。所以我看到上面的行,没有其他任何内容,只是空白页。

我将向您展示 gui.gwt.html:

<module>
    <!-- Specify the app entry point class.-->
    <entry-point class='com.something2.client.GUI'/>

    <inherits name='com.google.gwt.user.User'/> 
    <inherits name='com.google.gwt.user.User'/> 
    <inherits name="com.google.gwt.http.HTTP"/>
    <inherits name="com.google.gwt.xml.XML" />
    <servlet path='...' class='...l'/> // I have several servlets here, but I don't think they are causing issues here.
</module>

要添加的内容: 我正在使用从GWT java代码内部创建的iframe,我更改域的目的是能够与已经在html页面头部将document.domain定义为something2.com的iframe进行通信(与我相同或至少与我想做的相同)

所以,我不知道我在这里做错了什么。

Hello I'm developing a GWT application that has iframes inside. Im testing in localhost with Tomcat 6 and IE8.

I changed localhost domain (in hosts file: C:\WINDOWS\system32\drivers\etc\hosts) to be something1.something2.com, so now I have in my hosts file:

127.0.0.1 something1.something2.com

So, I run my Tomcat6 in IE8 something1.something2.com:8080/mygwtapp and mygwtapp runs OK.
The problem is when I change document.domain into file.html of GWT app.
In gui.html I have this:

<html>
    <head>
        <title>...</title>
        <style>...</style>
        <script language="javascript">
            document.write(document.domain);    
            document.domain = "something2.com"
            document.write(document.domain);
        </script>
        <meta name='gwt:module' content='scripts/com.something2.gui=com.something2.gui'>
    </head>
    <body>
        <script language="javascript" src="scripts/gwt.js"></script>
        <iframe id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe>
        <table align=center>
            <tr>
                <td id="slot1"></td>
                <td id="slot2"></td>
            </tr>
        </table>

    </body>
</html>

So, I run my app again with this gui.html and I get:

something1.something2.comsomething2.com

(just like that at the top) That is expected, but then all that I get is a blank page. So I see the line above and nothing else, just blank page.

I'll show you the gui.gwt.html:

<module>
    <!-- Specify the app entry point class.-->
    <entry-point class='com.something2.client.GUI'/>

    <inherits name='com.google.gwt.user.User'/> 
    <inherits name='com.google.gwt.user.User'/> 
    <inherits name="com.google.gwt.http.HTTP"/>
    <inherits name="com.google.gwt.xml.XML" />
    <servlet path='...' class='...l'/> // I have several servlets here, but I don't think they are causing issues here.
</module>

Something to add:
Im working with iframes that are created from inside GWT java code, my purpose to change domain is to be able to communiate with iframes that has already defined the document.domain in its head of html page to be something2.com (same as me or at least same as what I 'm trying to do)

So, I don't know what I am doing wrong here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橙味迷妹 2024-10-26 15:32:20

这是因为 GWT 在 iframe 中加载自身。您可以将该行添加到 gwt.xml 文件中,以便在不使用 iframe 的情况下加载:

但是,您将失去 DevMode 支持。有一个 xsiframe 链接器(它使用

This is because GWT loads itself within an iframe. You can add that line to your gwt.xml file to load without iframes:

<add-linker name="xs" />

You'll lose DevMode support however. There's a xsiframe linker (which loads code using <script> tags and injects it into an iframe to isolate it from the page) that has DevMode support, but I don't know if it'd work with your document.domain setup.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文