a.asp<BODY>
<FORM METHOD=POST ACTION="" name="frm1"><IFRAME name="smallpic" marginWidth="0" marginHeight="0" src="frm_b.html?id=xxx" frameBorder="0" height="510" scrolling="no"></IFRAME>
<INPUT TYPE="hidden" NAME="aa"></FORM>
</BODY>
b
function show(temp)
{
top.frm1.aa.value = temp;
alert(top.frm1.aa.value)}
<FORM METHOD=POST ACTION="" name="frm1"><IFRAME name="smallpic" marginWidth="0" marginHeight="0" src="frm_b.html?id=xxx" frameBorder="0" height="510" scrolling="no"></IFRAME>
<INPUT TYPE="hidden" NAME="aa"></FORM>
</BODY>
b
function show(temp)
{
top.frm1.aa.value = temp;
alert(top.frm1.aa.value)}
<script>
a = 1;
function aa(value)
{
document.write(value);
}
</script>
<iframe src="bb.htm"></iframe>//bb.htm
<script>
top.aa(123)
</script>
这样虽然实现了在aa中打印,但问题是把aa.htm冲掉了,所以只要你用document.write都会有这样的问题
解决办法是在要打印的那个页面中加入<div>
现在我将你的b.asp修改以在b中打印:
加入div
function show(temp)
{
window.parent.frm1.aa.value = temp;
window.parent.temp_Str = temp;
document.getElementById("showaa").innerText = temp;
}
<div id=showaa></div>
<img border='0' src='xxx' onclick=javascript:show('111')></img>
<img border='0' src='xxx' onclick=javascript:show('222')></img>
<img border='0' src='xxx' onclick=javascript:show('333')></img>