如何隐藏< A>的href属性使用window.print时通过css标记 [英] How to hide href attribute of <A> tag via css when using window.print
问题描述
我有一个php页面,有一个按钮,用户可以通过window.print函数打印。
I've a php page, with a button that able the user to print via window.print function.
我需要知道如何隐藏打印页面时html标记的href属性
I'd need to know how to hide the href attribute of an html tag when printing the page
示例:
如果标记如下:
Example: if the tag is like follow:
<a href='myurl.com'>HELLO</a>
我只想显示HELLO。
I want to display just HELLO.
我必须这样做只有当我使用window.print。
I've to do this only when i use window.print.
我已经设置了css以这种方式打印:
I've already set up the css for printing in this way:
@media print {
body * {
visibility:hidden;
}
#section_to_print, #section_to_print * {
visibility:visible;
}
#section_to_print {
position:absolute;
left:0;
top:0;
}
/*
//HERE I NEED A RULE TO HIDE
// ONLY HREF ATTRIBUTE BUT NOT CONTENT OF A TAG
//BUT IN THIS WAY THEY HIDE THE WHOLE TAG OF COURSE
#section_to_print a {
display:none;
}
*/
@page { size: landscape; }
}
并且所有工作都正确,除了使用href打印的链接部分。
And all works correctly, except for the link that was printed with the href part.
谢谢您,
Francesco
Thank you, Francesco
推荐答案
谢谢,解决方案我发现工作形式类似于你的
Thank you, the solution i've found that work form me is similar to your
#section_to_print a[href]:after { display:none; }
事实上,问题是由一些css生成的,包含如下的规则:
In fact, the problem was generated by some css containing a rule like follow:
a:link:after, a:visited:after {content:" (" attr(href) ")";font-size:90%;}
按此链接建议:
stackoverflow.com/questions/4834517/...
stackoverflow.com/questions/4834517/…
但是,非常感谢:)问候,Francesco
However, thank to much :) Regards, Francesco
这篇关于如何隐藏< A>的href属性使用window.print时通过css标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!