如何控制嵌入的的布局?

发布于 2024-10-01 02:56:19 字数 755 浏览 0 评论 0原文

Page1.html 有

<html><head>
</head>
<body>
[<span class="foo">span unchanged</span>]
<script type="text/javascript">
    var a = document.getElementsByClassName('foo').item(0);
    var synth = '<object data="http://localhost/~bruceaxtens/Page2.html">Page2.html not found</object>';
    a.innerHTML = synth;
</script>
</body>
</html>

所以有方括号应该包含将由 Page2.html 返回的文本

Page2.html 包含

<html>
<head></head>
<body>
<script type="text/javascript">
document.write("Hello World");
</script>
</body>
</html>

但是我得到的是页面顶部的“Hello World”和几英寸的括号再往下。

有什么办法让两者保持在一起吗?

Page1.html has

<html><head>
</head>
<body>
[<span class="foo">span unchanged</span>]
<script type="text/javascript">
    var a = document.getElementsByClassName('foo').item(0);
    var synth = '<object data="http://localhost/~bruceaxtens/Page2.html">Page2.html not found</object>';
    a.innerHTML = synth;
</script>
</body>
</html>

So there are square brackets which should enclose the text which will be handed back by Page2.html

Page2.html contains

<html>
<head></head>
<body>
<script type="text/javascript">
document.write("Hello World");
</script>
</body>
</html>

What I get however is the "Hello World" at the top of the page and the brackets a couple of inches further down.

Is there any way of keeping the two together?

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

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

发布评论

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

评论(1

っ〆星空下的拥抱 2024-10-08 02:56:19

我这样回答自己:

不要返回 HTML 并在不同浏览器中遇到对象处理问题,而是交回 Javascript 并在客户端 DOM 的上下文中执行它。

I answer myself thus:

Instead of returning HTML and have issues with OBJECT handling in different browsers, hand back Javascript and execute it in the context of the client's DOM.

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