Here is my code:
<html>
<head>
<script type="text/javascript">
function displaymessage()
{
win=window.open();
win.document.write("<html>");
win.document.write("<head>");
win.document.write("<style type=\"text/css\">");
win.document.write(".vis{visibility:hidden;}");
win.document.write("</style>");
win.document.write("</head>");
win.document.write("<body>");
win.document.write("<table align=\"center\">");
win.document.write("<tr><td>result:</td><td>100,--€</td></tr>");
win.document.write("<tr><td colspan=\"2\" id=\"idcko\"><input type=\"button\" value=\"click\" onclick=\"window.print();vlozenie()\"/></td></tr>");
win.document.write("</table>");
win.document.write("</body>");
win.document.write("</html>");
}
</script>
</head>
<body>
<form>
<input type="button" value="Click me!" onclick="displaymessage();" />
</form>
<script type="text/javascript">
function vlozenie()
{
var y = win.document.getElementById("idcko");
y.innerHTML="<input type=\"button\" value=\"click2\" class=\"vis\"/>";
}
</script>
</body>
</html>
Now I want to print the rendered page, but I want to hide the print button. So is it possible to write some JavaScript functions in an "onclick" event, or may I access the JavaScript function which is located on the mother page? I found some examples to add "class" attributes for HTML elements:
$("#idcko").addClass("vis");
but it has to be written in JavaScript tags, which I can`t write like this:
win.document.write("<script type=\"text/javascript\">some functions()</script>");
because the rendered page is now incorrect.