打印修改后的网页而不显示它
我正在尝试在电子商务产品页面上实现“打印此页面”。它将没有不必要的部分,如顶部导航、页脚、添加到购物车按钮等。我希望它像 target.com 一样工作 <一href="http://www.target.com/Avalon-Vitamin-Moisture-Plus-Lotion/dp/B00120ZAYI/ref=sr_1_13?ie=UTF8&searchView=grid5&keywo rds=维生素&fromGsearch=true&sr=1-13&qid=1305580954&rh=&searchRank=target104545&id=Avalon%20Vitamin%20M oisture%20Plus%20Lotion&node=1038576|1287991011&searchSize=30&searchPage=1&searchNodeID=1038576|1287991011&s searchBinNameList=subjectbin%2Cprice%2Ctarget_com_primary_color-bin%2Ctarget_com_size-bin%2Ctarget_com_brand-bin&frombrowse=0" rel="nofollow">http://www.target.com/Avalon-Vitamin-Moisture-Plus-Lotion/dp/B00120ZAYI/ref=sr_1_13?ie=UTF8&searchView=grid5& ;关键字=维生素&fromGsearch=true&sr=1-13&qid=1305580954&rh=&searchRank=target104545&id=Avalon%20Vitamin% 20Moisture%20Plus%20Lotion&node=1038576|1287991011&searchSize=30&searchPage=1&searchNodeID=1038576|1287991011&s searchBinNameList=subjectbin%2Cprice%2Ctarget_com_primary_color-bin%2Ctarget_com_size-bin%2Ctarget_com_brand-bin&frombrowse=0
如果您尝试打印它,则只会打印必要的内容。我很困惑如何实施它。我是否应该创建产品页面的修改版本并打印它而不向用户显示?请指教。
I'm trying to implement "print this page" on an e-commerce product page. It will be without needless sections like top navigation, footer, add to cart button etc. I want it to work like target.com
http://www.target.com/Avalon-Vitamin-Moisture-Plus-Lotion/dp/B00120ZAYI/ref=sr_1_13?ie=UTF8&searchView=grid5&keywords=vitamins&fromGsearch=true&sr=1-13&qid=1305580954&rh=&searchRank=target104545&id=Avalon%20Vitamin%20Moisture%20Plus%20Lotion&node=1038576|1287991011&searchSize=30&searchPage=1&searchNodeID=1038576|1287991011&searchBinNameList=subjectbin%2Cprice%2Ctarget_com_primary_color-bin%2Ctarget_com_size-bin%2Ctarget_com_brand-bin&frombrowse=0
If you try to print it, only essential content gets printed. I'm confused how to implement it. Should I create a modified version of product page and print it without displaying it to a user? Please advise.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以设置一个自定义 CSS 页面,其中包含页眉、导航、页脚或您喜欢隐藏的任何内容,这样当用户单击打印时,Web 浏览器会查看打印 CSS 并按照您希望的方式执行操作。
例子是:
在 HTML
属性“media”下,只有在打印出来时才会使用 print。
在 main.css 的 CSS 中,可能看起来像...
在 print.css 的 CSS 中,它可能看起来像...
基本上,复制您正在使用的 CSS,然后设置 display: none;您不想打印的内容。
You're able to set a custom CSS page that has the header, navigation, footer or whatever you like hidden so when the user clicks print, the web browser looks at the print css and acts how you want it to.
Example of this is:
In the HTML
Under the attribute "media", print will only be used when printing it out.
In the CSS for main.css, could look like..
In the CSS for print.css, it can look like...
Basically, make a duplicate of the CSS you're using and just set display: none; to what you don't want to have printed.