Home >Web Front-end >JS Tutorial >The CSS centering code of JS printing interface is suitable for all browsers_javascript skills

The CSS centering code of JS printing interface is suitable for all browsers_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:55:141660browse
Copy code The code is as follows:

function preview(oper) {
if (oper < 10 ) {
bdhtml = window.document.body.innerHTML;//Get the html code of the current page
sprnstr = "";//Set the printing start area
eprnstr = "";//Set the print end area
prnhtml = bdhtml.substring(bdhtml.indexOf(sprnstr) 18); //Start the code Get html backward

prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));//Get html forward from the end code
window.document.body.innerHTML = prnhtml;
window.print();
window.document.body.innerHTML = bdhtml;
} else {
window.print();
}

}
# outer {
display:table;
height:400px;
#position:relative;
overflow:hidden;
}
#middle {
display:table-cell;
vertical-align:middle;
#position:absolute;
#top:50%;
}
#inner {
#position:relative;
#top: -50%;
}










Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn