Mozilla Firefox 边距空格

发布于 2024-10-09 09:57:27 字数 173 浏览 0 评论 0原文

当我尝试在网页的 Javascript 部分中使用带有对象标记参数的 document.write() 等语句时,Mozilla Firefox 似乎在页面边缘放置了额外的边距空格,而其他浏览器则表现正常。造成这种差异的原因是什么?我怎样才能摆脱这些边缘空间?

注意:(我正在尝试在 Web 应用程序中加载小程序。)

When I try to use a statement like document.write() with object tag parameters in Javascript part of a webpage, Mozilla Firefox seems to put extra marginal spaces on the edges of the page while other browsers behave normally. What is the reason of this difference? How can I get rid of these marginal spaces?

Note: (I'm trying to load an applet in a web application.)

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

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

发布评论

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

评论(3

无所谓啦 2024-10-16 09:57:27

我认为这里真正的答案是“不要使用 document.write”:-) 请参阅此相关的 SO 帖子了解原因:
为什么 document.write 被认为是“不好的做法”?

那么,如果不是 document.write,您应该做什么?嗯,理想情况下是 JQuery(恕我直言,这几乎是现在编写 JS 的要求)。使用jQUery,你的问题很简单:

$(document.body).append(
  "<object><embed type = 'application/x-java-applet;version=1.5' \ CODE = ...");

如果你不想使用jQuery(不是潜意识消息:使用jQuery!),你也可以使用innerHTML(如Kiva建议),或document.createElement + document.body .appendChild 将元素添加到页面。

我怀疑如果您使用这些技术中的任何一种,而不是 document.write,您将看到与首先将元素放在 HTML 中类似的行为。

I think the real answer here is "don't use document.write" :-) See this related SO post for why:
Why is document.write considered a "bad practice"?

So what should you do if not document.write? Well, ideally JQuery (it's all but a requirement for writing JS nowadays IMHO). With jQUery your problem is as simple as:

$(document.body).append(
  "<object><embed type = 'application/x-java-applet;version=1.5' \ CODE = ...");

If you don't want to use jQuery (not-so-subliminal message: use jQuery!) you can also use either innerHTML (as Kiva suggested), or document.createElement + document.body.appendChild to add the element to the page.

I suspect if you use any of these techniques, instead of document.write, you'll see similar behavior to just having the element there in the HTML in the first place.

无人接听 2024-10-16 09:57:27

你的代码是什么?

也许 Firefox 为 applet 应用程序添加了默认边距,请尝试使用 firebug 查看此内容。

What is your code ?

Maybe Firefox add a default margin for applet application, try to look at this with firebug.

豆芽 2024-10-16 09:57:27

也许是 CSS 的问题。可能即将解决这种情况:

html, body{margin: 0; padding: 0;}

Maybe the problem in the CSS. May be about to fix this situation:

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