我重写了一些代码并尝试了这个,但是我的打印功能不起作用。如果它开始工作,是否只会打印 div id 示例?
<div id='example'>
<h3>Saturday Sept. 8th</h3>
</p><strong>7:00AM-8:00AM</strong> </p>
<input type="radio" name= "one" /><label> meditation meeting</label>
<br>
<input type="radio" name= "one" <label> step 1 workshop</label>
<br>
<input type="radio" name= "one"<label > Bottom lines</label>
<br>
<input type="radio" name= "one"<label > Top Lines</label>
<br>
<input type="radio" name= "one"<label> Sponsorship</label>
<br>
<input type="radio" name= "one"<label> Being a Sponsee</label>
<br>
<br>
</p> <strong>8:15AM-9:15AM</strong></p>
<input type="radio" name= "two"<label> Step 2 workshop</label>
<br>
<input type="radio" name= "two"<label>Living life</label>
<br>
<input type="radio" name= "two"<label> chairing a meeting</label>
<br>
<input type="radio" name= "two"<label>Service work</label>
<br>
<input type="radio" name= "two"<label> Accepting gifts</label>
<br>
<input type="radio" name= "two"<label>Principles before Personalities</label>
<br>
<input type="button" value="Print" onclick="printPage('example');"></input>
</div>
最佳答案
您无法在网络浏览器中控制打印,因为这是一个用户端功能,因此需要一种解决方法/hackie 方法,我通常做的是以下内容:
您可以使用 z-index
属性制作一个显示在屏幕中间的 di,覆盖它后面的所有内容
然后填入需要打印的内容
然后右击==>打印
然后在打印对话框中,您可以根据需要调整打印内容的大小。
关于html - 打印网页的特定区域并突出显示内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50136066/