如何控制嵌入的
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我这样回答自己:
不要返回 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.