html - JavaScript @media print stylesheet not working -
i have started trying make simple html , css webpages while incorporating bit of javascript. i'm trying make simple print button doesn't show when print it. i've searched around sa various answers , i've seen lot of things link media= "print"
. in stylesheet class write either display: none
or visibility: hidden
. apply button.
the problem when try doing it, doesn't turn invisible when page preview pops up. here main code:
<link rel="stylesheet" href="print.css" type="text/css" media="print" /> <script type = "text/javascript"> function newperson(firstname, lastname, age, gender, birthmonth, birthdate) { this.firstname = firstname; this.lastname = lastname; this.age = age; this.gender = gender; this.birthmonth = birthmonth; this.birthdate = birthdate; this.birthyear = birthdaycalculate; } function birthdaycalculate() { var date = new date(); var curyear = date.getfullyear() var curmonth = date.getmonth() var birthyear = curyear - this.age if (this.birthmonth > curmonth) { birthyear -- } return birthyear } function testfunction(form) { var firstname = form.firstname.value var lastname = form.lastname.value var age = form.age.value var gender = form.gender.value var birthmonth = form.birthmonth.value var birthdate = form.birthdate.value var new1 = new newperson(firstname, lastname, age, gender, birthmonth, birthdate) var person = new1.firstname + " " + new1.lastname + " " + new1.age + " , " + new1.gender + " , born on " + new1.birthmonth + "/" + new1.birthdate + "/" + new1.birthyear() + "." + "<br />" document.write(person); winvar = window.open(); winvar.document.write(person); winvar.focus(); winvar.document.write( "<input type='button' " + "onclick= 'window.print();'" + "value ='print page' " + "class = 'print' " + "/>");} </script>
i think you'd able tell used forms. don't think need show this. print .css extremely simple too:
.print{ visibility: hidden }
does see wrong script? little else, i'm using google chrome.
css not in case use javascript instead. have this:
assume print button <input type="button" value="print" onclick="this.setattribute('hidden''hidden')"/>
hide button when clicked using setattribute function.
hope work..
Comments
Post a Comment