日期:2014-05-16  浏览次数:20372 次

通过javascript取得 对象的内容
HTML code

<script type="text/javascript">
function myFunction()
{
return ("Hello, M JavsScript!")
}
</script>

<%
'我想实现的效果是:c="Hello, M JavsScript!"
response.write c
%>


这个要如何才能实现呢?

另:我知道可以这样:
<script type="text/javascript">
document.write(myFunction())
</script>
但是我要的不是这样的效果,我是想把从js中取得的 内容 存入到一个变量 c 中,然后把c存到数据库中



------解决方案--------------------
<%
c = " Hello, M JavsScript!"
%>
<script type="text/javascript">
function myFunction()
{
return ("<%=Replace(c,"""","\""")%>");
}
</script>

------解决方案--------------------
用ajax来处理吧
------解决方案--------------------
还是要递交表单,可以借助隐藏的iframe

<iframe name="hf" width="0" height="0">
<form action="xx.asp" name="form1" target="hf">
<input type="hiden" name="c">
</form>
<script>
function myFunction()
{
return "Hello, M JavsScript!"
}
function show(s){
alert(s)
}
function dosubmit(){
document.form1.c.value = myFunction();
document.form1.submit()
}
</script>

---------
xx.asp
<%
c = request("c")
.....存入数据库
%>
<script>
parent.show("ok"); //将返回的数值传给原窗口
location.replace("about:blank");
</script>