javascript - Loading Image into document.body Background -


I am trying to draw an image (in this case, / camera / frame , Which is a well-known JPG), and it is loaded as the backdrop of its document.body .

My code is so far:

  Miscellaneous background image = new image (); BackgroundImage.onload = function () {console.log ("Onload"); Document.body.style.backgroundImage = this.src; }; BackgroundImage.src = 'camera / frame'; Expected as   

"Onload" , and this prints the entire URL to / camera / frame Still remains Document.body.style.backgroundImage "" .

I believe you can remember two things.

  var path = 'path / to / image.jpg'; Document.body.style.background = 'url (' + path + ')';    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -