【发布时间】:2017-12-09 08:47:02
【问题描述】:
第一个运行的 chrome 插件。我没有详细信息。
在我打印This link的内容之前,我想得到具体的部分。
<table class="receiptSectionTable2Col" >
我怎样才能打印这个表的内容。 这可能吗?
【问题讨论】:
标签: google-chrome google-chrome-extension extension-methods
第一个运行的 chrome 插件。我没有详细信息。
在我打印This link的内容之前,我想得到具体的部分。
<table class="receiptSectionTable2Col" >
我怎样才能打印这个表的内容。 这可能吗?
【问题讨论】:
标签: google-chrome google-chrome-extension extension-methods
HTMLElement.prototype.printMe = printMe;
function printMe(query){
var myframe = document.createElement('IFRAME');
myframe.domain = document.domain;
myframe.style.position = "absolute";
myframe.style.top = "-10000px";
document.body.appendChild(myframe);
myframe.contentDocument.write(this.innerHTML) ;
setTimeout(function(){
myframe.focus();
myframe.contentWindow.print();
myframe.parentNode.removeChild(myframe) ;// remove frame
},3000); // wait for images to load inside iframe
window.focus();
}
在您的情况下的用法:
document.getElementsByClassName("receiptSectionTable2Col")[0].printMe();
【讨论】: