views:

71

answers:

4

I want to change the default margins of Browser through JavaScript because I want to print the displayed document on page but the margins are different on different browser??? plz help me to change default margins of browser. if you have any solution tell me.

A: 

use jquery

$(document).ready(function() {
       $("body").css("margin","0");
});

Using CSS

body { margin:0; }
Starx
A: 

CSS:

body, html { margin:0 }

or

* { margin:0 }

or look into CSS reset. Would recommend this over JavaScript.

Louis
+3  A: 

Not javascript, but if you are looking for specific styles to use for printing you can use:
<link rel="stylesheet" type="text/css" href="print.css" media="print" />

where print.css would contain something like

* { margin:0 }
zipcodeman
+2  A: 

I would recommend adding reset.css to your page, and probably to all of your pages/projects.
This way you should be able to eliminate all differencies in default style values amongst browsers.

EDIT: check out one of the most valuable threads at StackOverflow.com

Jaroslav Záruba
superb dear thank you
Govind KamalaPrakash Malviya
you're welcome... yeah i have that from Stackoverflow :) see edit
Jaroslav Záruba