document-body

What's the meaning of page and page.body in Capybara

这一生的挚爱 提交于 2019-12-01 23:26:35
问题 I'm a newbie try to test my Rails project using Capybara, but I'm confused with the meaning of page and page.body, when I try to detect some string from my div: (in :js=>true mode) <div>"some content"</div> Some of my test will pass with page.should have_content "some content" Some will pass with page.body.should have_content "some content" I try to puts the content but only "page.body" will give me some valuable information, the "page" itself will show me nothing, and I can't find any solid

What's the meaning of page and page.body in Capybara

醉酒当歌 提交于 2019-12-01 22:02:30
I'm a newbie try to test my Rails project using Capybara, but I'm confused with the meaning of page and page.body, when I try to detect some string from my div: (in :js=>true mode) <div>"some content"</div> Some of my test will pass with page.should have_content "some content" Some will pass with page.body.should have_content "some content" I try to puts the content but only "page.body" will give me some valuable information, the "page" itself will show me nothing, and I can't find any solid explanation about what page and page.body did. Can anyone help me? page is the current Capybara session

Why doesn't HTML body background-color obey margin?

烂漫一生 提交于 2019-12-01 21:34:30
According to w3, the margin of an element is transparent: I've built a very basic HTML page: <!DOCTYPE html> <html lang="en"> <head> <title>Document</title> <style> body { background-color: red; } </style> </head> <body></body> </html> In Chrome, the inspector reports that "body" has an 8px margin: But on the page, the margin is full of the background color! (Notice that there's no space between my bookmarks bar and the red background - I promise I haven't scrolled. What's up with that? The CSS specification special cases it. The background of the root element becomes the background of the

Append text WebEngine - JavaFX

浪子不回头ぞ 提交于 2019-11-30 22:32:55
How can I append text to webengine? I tried this: public TabMessage(String title) { super(title); view = new WebView(); engine = view.getEngine(); engine.loadContent("<body></body>"); view.setPrefHeight(240); } private void append(String msg){ Document doc = engine.getDocument(); Element el = doc.getElementById("body"); String s = el.getTextContent(); el.setTextContent(s+msg); } But document is null You can also use JavaScript to do the append. final WebEngine appendEngine = view.getEngine(); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) {

Scroll listener on body

断了今生、忘了曾经 提交于 2019-11-30 20:25:27
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 work? Sorry for nubies question... Try with: $(window).scroll(function(){ console.log('SCROLL BODY'); }); This should be supported by all browsers. All the answers above expect jQuery being the framework of use. A framework agnostic / plain JS implementation could look like this ES 5: // ES 5 : document.getElementsByTagName('body')[0].onscroll = function

Random body background-image

妖精的绣舞 提交于 2019-11-30 05:25:22
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 right? Thanks, EDIT (Sorry, forgot to attach the code - found in the web): $(document).ready(function(){ bgImageTotal=9; randomNumber = Math.round(Math.random()*(bgImageTotal-1))+1; imgPath=('../img/bg/'+randomNumber+'.jpg'); $('body').css('background-image', ('url("'+imgPath+'")')); }); Check out this tutorial: http://briancray.com/2009/12/28/simple

Random body background-image

流过昼夜 提交于 2019-11-29 03:45:48
问题 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 right? Thanks, EDIT (Sorry, forgot to attach the code - found in the web): $(document).ready(function(){ bgImageTotal=9; randomNumber = Math.round(Math.random()*(bgImageTotal-1))+1; imgPath=('../img/bg/'+randomNumber+'.jpg'); $('body').css('background

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

风格不统一 提交于 2019-11-29 01:00:55
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 doing this so when I scroll past a point, I change the opacity of an element. I'm doing this using an MVS solution and I don't have the ability to push this to an external site so you can look. Here's a quick snippet: var opacity = 1; var scrollTop = $('body').scrollTop(); if (scrollTop > 200) { opacity = 0.1; } $('#element).css('opacity', opacity); If

Find body tag in an ajax HTML response

别说谁变了你拦得住时间么 提交于 2019-11-28 07:29:45
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) { divs = $(this).html(); $('#result').append('' + divs + ''); }) }, 'html'); }); The problem is that when I change a in body I get nothing (no error, just no html). Im assuming body is a tag just like 'a' is? What am I doing wrong? So this works for me: mas = $(data).find('a'); But this doesn't: mas = $(data).find('body'); Parsing the returned HTML through a jQuery object (i

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

人走茶凉 提交于 2019-11-27 20:33:21
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 write your javascript In the <head> In the <body> with a $(document).ready() I could be stupid, but I've had a few times when my JavaScript (/jQuery) wasn't executed because of the wrong place or yes or no doc.ready() command. So I'm really wondering so. Same goes for jQuery and 'var' command $(document).ready() simply ensures that all DOM elements