我有一个小问题,我不知道原因。我设置isset触发点击问题(Php,jquery,iframe)
1-如果您单击打印按钮然后print.php页面将自动打印。
2-如果您提交表格,那么print.php页面将自动打印。
问题在第二个选项。页面打印自动完美,但如果我再次点击打印按钮,它不会再次打印页面。
我正在使用firefox。
<script language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
function loadiFrame(src)
{
$("#iframeplaceholder").html("<iframe id='myiframe' name='myname' src='" + src + "' frameborder='0' vspace='0' hspace='0' marginwidth='0' marginheight='0' width='1' scrolling='no' height='1' />");
}
$(function()
{
$("#printbutton").bind("click",
function() {
loadiFrame('print.php');
$("#myiframe").load(
function() {
window.frames['myname'].focus();
window.frames['myname'].print();
}
);
}
);
});
</script>
<?
if (isset($_POST['formSubmit']))
{
echo "form submitted";
?>
<script type="text/javascript">
$(document).ready(function(){
$('#printbutton').trigger('click');
});
</script>
<? } ?>
</head>
<body>
<table border="1">
<tr>
<td><input type="button" id="printbutton" value=" Print " /><div id="iframeplaceholder"></div></td>
</tr>
</table>
<form action="auto.php" method="post">
<input name="formSubmit" type="submit" value="Submit" />
</form>
</body>
你好,这次在提交表单后根本没有打印。打印机开启,但不打印时熄灭。 – emre 2010-11-09 05:37:43
我测试了代码,它工作得很好!你有没有改变.load()方法.ready()? – Mohammad 2010-11-09 08:51:49