1

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.)

Juvanis
  • 25,000
  • 3
  • 61
  • 84

3 Answers3

1

What is your code ?

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

Kiva
  • 8,863
  • 16
  • 56
  • 91
  • document.write(" tag in the body of the document there is no problem, but we have to it in javascript. – Juvanis Dec 24 '10 at 14:55
  • ok, try to include your code in a div with this code: document.getElementById('divId').innerHTML = '....'; this code include the objet in a div and not in the end of the document. – Kiva Dec 24 '10 at 14:59
1

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.

Community
  • 1
  • 1
machineghost
  • 28,573
  • 26
  • 128
  • 197
0

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

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