I am currently working on a JavaScript app and I am trying to implement a button that will allow users to print a specific div. To achieve this, I am utilizing a jQuery plugin called printThis (github link) as well as attempting to use window.print().
$("#printbtn").click(function(ev){
$("#dropzone").printThis();
ev.preventDefault();
ev.stopPropagation();
});
In the menu, there are options for changing the background color of the dropzone, adding new divs, and more.
function putGrid(){
$("#dropzone").css("background-image", "url("+blogUrl+"/wp-content/uploads/2013/05/gridMedium.png)");
$("#dropzone").css("background-repeat", "repeat");
}
function resetBackground (){
$("#dropzone").css("background", "white");
}
<div id="dropzone" style="background-image: url(http://Secret_Domain_xP.es/wp-content/uploads/2013/05/gridMedium.png); background-repeat: repeat repeat;">
</div>
However, I have encountered a problem:
The css() function adds a style attribute, but printing only works with CSS files ("blahblah.css" or "<style></style>
"). Does anyone know how to resolve this issue?