开发者

Mozilla Firefox margin spaces

开发者 https://www.devze.com 2023-02-01 06:12 出处:网络
When I try to use 开发者_如何学JAVAa 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

When I try to use 开发者_如何学JAVAa 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.)


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.


What is your code ?

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


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

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

精彩评论

暂无评论...
验证码 换一张
取 消