Questions tagged [document-body]

The body is part of an HTML document. It contains the content of that document.

250 questions
111
votes
6 answers

Difference between $(document.body) and $('body')

I am a jQuery beginner and while going through some code examples I found: $(document.body) and $('body') Is there any difference between these two?
user1617640
32
votes
4 answers

scrollTop() returns 0 in Firefox, but not in Chrome

Not sure if there's another question regarding this, if so I apologize and please don't release the hounds. Using the html5 doctype and doing a quick console.log off my scroll listener that tells me the value of scrollTop() value. I'm basically…
lxndr
  • 692
  • 1
  • 11
  • 25
23
votes
5 answers

Find body tag in an ajax HTML response

I'm making an ajax call to fetch content and append this content like this: $(function(){ var site = $('input').val(); $.get('file.php', { site:site }, function(data){ mas = $(data).find('a'); mas.map(function(elem, index) { …
Youss
  • 3,966
  • 12
  • 48
  • 104
22
votes
3 answers

When do you put Javascript in body, when in head and when use doc.load?

Possible Duplicate: Where to place Javascript in a HTML file? Should I write script in the body or the head of the html? I've always wondered, mainly because when creating pages I always run into trouble, based on the following thing: When do you…
Sander Schaeffer
  • 2,528
  • 7
  • 25
  • 52
15
votes
2 answers

Browser user agent style sheet margin 8px

I was just wonerdering about a white space all around a website. I found out it is there because of the user agent style sheet (Google Chrome) and there is set a margin of 8px to the body tag as default. How to solve this is not a problem, but I am…
Philipp Sch
  • 153
  • 1
  • 1
  • 4
8
votes
4 answers

Scroll listener on body

I would like to ask about scroll listener. I want to add scroll listener on body but it seems doesnt work. $('body').scroll(function(){ console.log('SCROLL BODY'); }); I create basic example on fiddle, can someone explain me why it doesn't to…
user1297783
  • 143
  • 1
  • 1
  • 8
7
votes
2 answers

Random body background-image

I've tried several tutorial on the web and none seems to work properly. What I'm trying to do is quite simple I think: I have 9 different .jpg images that I need to randomly show up on page load - to be background. This should be fairly simple…
asirgado
  • 225
  • 3
  • 4
  • 7
6
votes
3 answers

How can I disable print-screen functionality for a webpage in all browsers?

Using the following we can disable print-screens or screenshots in Internet Explorer: But these don't work in…
ponds
  • 1,939
  • 4
  • 15
  • 11
6
votes
3 answers

why do browsers style a predefined margin into all webpages?

Why do all* browsers style an arbitrarily sized margin on the element of all webpages? I'm not surprised by this, as I've been making webpages for years now, but I just assumed it was part of the spec, in the same way text inside
Ben Leggiero
  • 25,904
  • 38
  • 161
  • 267
6
votes
2 answers

JS - set window height using current window size

I have some CSS that needs the body to have a height set, but this needs to be done depending on the user. I have made some code that kind of works - it calculates the window height but it's not changing the body height. What am I doing…
cloggy
  • 145
  • 3
  • 3
  • 10
6
votes
3 answers

and Tags 100% Height Fail

I have an application which requires me to use CSS to set the height of the and tags to 100%, like this (JSFiddle version): html, body { display: block; height: 100%; margin: 0px; padding: 0px; width: 100%; } body { …
Oliver Spryn
  • 15,563
  • 30
  • 91
  • 184
6
votes
5 answers

Will style css tag render in body?

I am using a CMS and apparently it has a bug that will not allow me to add any content to the of a blog post. It inserts everything into the body which in most cases that works okay but in an instance of code like this:
L84
  • 42,350
  • 55
  • 167
  • 243
5
votes
5 answers

Why doesn't the z-index style apply to the element?

The z-index style allows you to control what order boxes are painted in. For example, you can make a child element be painted below its parent element: #parent { background: rgba(33, 33, 33, 0.7); } #child { width: 100px; height: 100px; …
Peter Olson
  • 121,487
  • 47
  • 188
  • 235
5
votes
5 answers

Why is document.body == null in Firefox but not Safari

I have a problem with a page where I am trying to get colorbox (a kind of lightbox for jQuery) working. It doesn't work apparently due to the document.body being null in FireFox (3.5.3). This is not the case in Safari (4.0.3) where the colorbox…
dlamblin
  • 40,676
  • 19
  • 92
  • 127
5
votes
2 answers

My body background color disappears when scrolling

I hope someone can help. I've set my body height property to 100% which is fine when all the content is on the screen at one time. However when i need to scroll (when minimizing the window) the body color disappears, leaving just the color i set for…
KAY DEE EMM
  • 65
  • 1
  • 1
  • 6
1
2 3
16 17