<script>
parent.followTd.innerHTML='<%=bodycontent%>';
</script>
可是我的bodycontent变量中的内容也有一个脚本函数即有<script language=vbscript>function备</script>,可有这个脚本后就无法用innerHTML传这bodycontent里面的HTML代码了,如把这个脚本去掉依然可以正常传,我知道好象有点<script>嵌套<script>,这种情况有没有什么办法以可以解决呀
5 个解决方案
#1
是个问题,关注ing
#2
参考:
f.htm
<div id="div1"></div>
<iframe id="iframe1" src="test.htm"></iframe>
test.htm
<div id="div2">
<table border="1">
<tr><td><input type="button" value="test" onclick="test()"></td></tr>
</table>
</div>
<script language="vbscript">
sub test()
msgbox "vb test"
end sub
</script>
<p>
<input type="button" value="Trans" onclick="trans();">
<script language="javascript">
function trans(){
var ostr = div2.innerHTML;
var sScript = "<SCRIPT language=\"vbscript\" defer>"
sScript = sScript + "function test()"
sScript = sScript + " msgbox \"Hello from inserted script.\""
sScript = sScript + "end function"
sScript = sScript + '</script' + '>';
parent.div1.insertAdjacentHTML("afterBegin",ostr + sScript);
}
</script>
f.htm
<div id="div1"></div>
<iframe id="iframe1" src="test.htm"></iframe>
test.htm
<div id="div2">
<table border="1">
<tr><td><input type="button" value="test" onclick="test()"></td></tr>
</table>
</div>
<script language="vbscript">
sub test()
msgbox "vb test"
end sub
</script>
<p>
<input type="button" value="Trans" onclick="trans();">
<script language="javascript">
function trans(){
var ostr = div2.innerHTML;
var sScript = "<SCRIPT language=\"vbscript\" defer>"
sScript = sScript + "function test()"
sScript = sScript + " msgbox \"Hello from inserted script.\""
sScript = sScript + "end function"
sScript = sScript + '</script' + '>';
parent.div1.insertAdjacentHTML("afterBegin",ostr + sScript);
}
</script>
#3
test.htm文件改一下:
<div id="div2">
<table border="1">
<tr><td><input type="button" value="test" onclick="test()"></td></tr>
</table>
<script language="vbscript" DEFER>
sub test()
msgbox "vb test"
end sub
</script>
</div>
<p>
<input type="button" value="Trans" onclick="trans();">
<script language="javascript">
function trans(){
var ostr = div2.innerHTML;
parent.div1.innerHTML = ostr;
}
</script>
方便点。
<div id="div2">
<table border="1">
<tr><td><input type="button" value="test" onclick="test()"></td></tr>
</table>
<script language="vbscript" DEFER>
sub test()
msgbox "vb test"
end sub
</script>
</div>
<p>
<input type="button" value="Trans" onclick="trans();">
<script language="javascript">
function trans(){
var ostr = div2.innerHTML;
parent.div1.innerHTML = ostr;
}
</script>
方便点。
#4
哦,知道了,关键是要把</script>分开。以前做过,支持楼上
#5
我是要用ASP脚本动态生成第二个<script>的,你看能传吗?
我的ASP代码如下:
vbstr=vbNewLine
vbstr=vbstr&"<script Language=""VBScript"">" & vbNewLine
vbstr=vbstr&"function do_qry"&flag_id&i&k&"()" & vbNewLine
vbstr=vbstr&"if trim(addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value)="""" then" & vbNewLine
vbstr=vbstr&"msgbox ""出库数量不能为空!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"else" & vbNewLine
vbstr=vbstr&"if not isnumeric(trim(addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value)) then" & vbNewLine
vbstr=vbstr&"msgbox ""请重新输入出库数量!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"else" & vbNewLine
vbstr=vbstr&"if int(trim(addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value))<=0 then" & vbNewLine
vbstr=vbstr&"msgbox ""请重新输入出库数量!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"if addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value-addform"&flag_id&i&k&".fqty"&flag_id&i&k&".value>0 then" & vbNewLine
vbstr=vbstr&"msgbox ""出库数量不能超过库存!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"if trim(addform"&flag_id&i&k&".InvoiceMode"&flag_id&i&k&".value)="""" then" & vbNewLine
vbstr=vbstr&"msgbox ""请选择开票模式!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".InvoiceMode"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"if trim(addform"&flag_id&i&k&".objfnumber"&flag_id&i&k&".value)="""" then" & vbNewLine
vbstr=vbstr&"msgbox ""请选择目的库!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".objfnumber"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".submit"&flag_id&i&k&"" & vbNewLine
vbstr=vbstr&"end function" & vbNewLine
vbstr=vbstr&"</script>" & vbNewLine
bodycontent=vbstr
把所得的HTML代码传回第一页(如单独页打出bodycontent是正常的,可不能用下在的来传)
<script>
parent.followTd<%=id%>.innerHTML='<%=bodycontent%>';
</script>
我的ASP代码如下:
vbstr=vbNewLine
vbstr=vbstr&"<script Language=""VBScript"">" & vbNewLine
vbstr=vbstr&"function do_qry"&flag_id&i&k&"()" & vbNewLine
vbstr=vbstr&"if trim(addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value)="""" then" & vbNewLine
vbstr=vbstr&"msgbox ""出库数量不能为空!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"else" & vbNewLine
vbstr=vbstr&"if not isnumeric(trim(addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value)) then" & vbNewLine
vbstr=vbstr&"msgbox ""请重新输入出库数量!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"else" & vbNewLine
vbstr=vbstr&"if int(trim(addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value))<=0 then" & vbNewLine
vbstr=vbstr&"msgbox ""请重新输入出库数量!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"if addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value-addform"&flag_id&i&k&".fqty"&flag_id&i&k&".value>0 then" & vbNewLine
vbstr=vbstr&"msgbox ""出库数量不能超过库存!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"if trim(addform"&flag_id&i&k&".InvoiceMode"&flag_id&i&k&".value)="""" then" & vbNewLine
vbstr=vbstr&"msgbox ""请选择开票模式!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".InvoiceMode"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"if trim(addform"&flag_id&i&k&".objfnumber"&flag_id&i&k&".value)="""" then" & vbNewLine
vbstr=vbstr&"msgbox ""请选择目的库!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".objfnumber"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".submit"&flag_id&i&k&"" & vbNewLine
vbstr=vbstr&"end function" & vbNewLine
vbstr=vbstr&"</script>" & vbNewLine
bodycontent=vbstr
把所得的HTML代码传回第一页(如单独页打出bodycontent是正常的,可不能用下在的来传)
<script>
parent.followTd<%=id%>.innerHTML='<%=bodycontent%>';
</script>
#1
是个问题,关注ing
#2
参考:
f.htm
<div id="div1"></div>
<iframe id="iframe1" src="test.htm"></iframe>
test.htm
<div id="div2">
<table border="1">
<tr><td><input type="button" value="test" onclick="test()"></td></tr>
</table>
</div>
<script language="vbscript">
sub test()
msgbox "vb test"
end sub
</script>
<p>
<input type="button" value="Trans" onclick="trans();">
<script language="javascript">
function trans(){
var ostr = div2.innerHTML;
var sScript = "<SCRIPT language=\"vbscript\" defer>"
sScript = sScript + "function test()"
sScript = sScript + " msgbox \"Hello from inserted script.\""
sScript = sScript + "end function"
sScript = sScript + '</script' + '>';
parent.div1.insertAdjacentHTML("afterBegin",ostr + sScript);
}
</script>
f.htm
<div id="div1"></div>
<iframe id="iframe1" src="test.htm"></iframe>
test.htm
<div id="div2">
<table border="1">
<tr><td><input type="button" value="test" onclick="test()"></td></tr>
</table>
</div>
<script language="vbscript">
sub test()
msgbox "vb test"
end sub
</script>
<p>
<input type="button" value="Trans" onclick="trans();">
<script language="javascript">
function trans(){
var ostr = div2.innerHTML;
var sScript = "<SCRIPT language=\"vbscript\" defer>"
sScript = sScript + "function test()"
sScript = sScript + " msgbox \"Hello from inserted script.\""
sScript = sScript + "end function"
sScript = sScript + '</script' + '>';
parent.div1.insertAdjacentHTML("afterBegin",ostr + sScript);
}
</script>
#3
test.htm文件改一下:
<div id="div2">
<table border="1">
<tr><td><input type="button" value="test" onclick="test()"></td></tr>
</table>
<script language="vbscript" DEFER>
sub test()
msgbox "vb test"
end sub
</script>
</div>
<p>
<input type="button" value="Trans" onclick="trans();">
<script language="javascript">
function trans(){
var ostr = div2.innerHTML;
parent.div1.innerHTML = ostr;
}
</script>
方便点。
<div id="div2">
<table border="1">
<tr><td><input type="button" value="test" onclick="test()"></td></tr>
</table>
<script language="vbscript" DEFER>
sub test()
msgbox "vb test"
end sub
</script>
</div>
<p>
<input type="button" value="Trans" onclick="trans();">
<script language="javascript">
function trans(){
var ostr = div2.innerHTML;
parent.div1.innerHTML = ostr;
}
</script>
方便点。
#4
哦,知道了,关键是要把</script>分开。以前做过,支持楼上
#5
我是要用ASP脚本动态生成第二个<script>的,你看能传吗?
我的ASP代码如下:
vbstr=vbNewLine
vbstr=vbstr&"<script Language=""VBScript"">" & vbNewLine
vbstr=vbstr&"function do_qry"&flag_id&i&k&"()" & vbNewLine
vbstr=vbstr&"if trim(addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value)="""" then" & vbNewLine
vbstr=vbstr&"msgbox ""出库数量不能为空!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"else" & vbNewLine
vbstr=vbstr&"if not isnumeric(trim(addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value)) then" & vbNewLine
vbstr=vbstr&"msgbox ""请重新输入出库数量!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"else" & vbNewLine
vbstr=vbstr&"if int(trim(addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value))<=0 then" & vbNewLine
vbstr=vbstr&"msgbox ""请重新输入出库数量!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"if addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value-addform"&flag_id&i&k&".fqty"&flag_id&i&k&".value>0 then" & vbNewLine
vbstr=vbstr&"msgbox ""出库数量不能超过库存!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"if trim(addform"&flag_id&i&k&".InvoiceMode"&flag_id&i&k&".value)="""" then" & vbNewLine
vbstr=vbstr&"msgbox ""请选择开票模式!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".InvoiceMode"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"if trim(addform"&flag_id&i&k&".objfnumber"&flag_id&i&k&".value)="""" then" & vbNewLine
vbstr=vbstr&"msgbox ""请选择目的库!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".objfnumber"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".submit"&flag_id&i&k&"" & vbNewLine
vbstr=vbstr&"end function" & vbNewLine
vbstr=vbstr&"</script>" & vbNewLine
bodycontent=vbstr
把所得的HTML代码传回第一页(如单独页打出bodycontent是正常的,可不能用下在的来传)
<script>
parent.followTd<%=id%>.innerHTML='<%=bodycontent%>';
</script>
我的ASP代码如下:
vbstr=vbNewLine
vbstr=vbstr&"<script Language=""VBScript"">" & vbNewLine
vbstr=vbstr&"function do_qry"&flag_id&i&k&"()" & vbNewLine
vbstr=vbstr&"if trim(addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value)="""" then" & vbNewLine
vbstr=vbstr&"msgbox ""出库数量不能为空!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"else" & vbNewLine
vbstr=vbstr&"if not isnumeric(trim(addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value)) then" & vbNewLine
vbstr=vbstr&"msgbox ""请重新输入出库数量!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"else" & vbNewLine
vbstr=vbstr&"if int(trim(addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value))<=0 then" & vbNewLine
vbstr=vbstr&"msgbox ""请重新输入出库数量!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"if addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".value-addform"&flag_id&i&k&".fqty"&flag_id&i&k&".value>0 then" & vbNewLine
vbstr=vbstr&"msgbox ""出库数量不能超过库存!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".gcsnum"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"if trim(addform"&flag_id&i&k&".InvoiceMode"&flag_id&i&k&".value)="""" then" & vbNewLine
vbstr=vbstr&"msgbox ""请选择开票模式!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".InvoiceMode"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"if trim(addform"&flag_id&i&k&".objfnumber"&flag_id&i&k&".value)="""" then" & vbNewLine
vbstr=vbstr&"msgbox ""请选择目的库!"",64,""提示""" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".objfnumber"&flag_id&i&k&".focus()" & vbNewLine
vbstr=vbstr&"exit function" & vbNewLine
vbstr=vbstr&"end if" & vbNewLine
vbstr=vbstr&"addform"&flag_id&i&k&".submit"&flag_id&i&k&"" & vbNewLine
vbstr=vbstr&"end function" & vbNewLine
vbstr=vbstr&"</script>" & vbNewLine
bodycontent=vbstr
把所得的HTML代码传回第一页(如单独页打出bodycontent是正常的,可不能用下在的来传)
<script>
parent.followTd<%=id%>.innerHTML='<%=bodycontent%>';
</script>