日期:2014-05-17  浏览次数:20447 次

<script type="text/javascript" src="CommentVote.aspx?modelID=111"></script>传值问题
index.htm页面<script type="text/javascript" src="CommentVote.aspx?modelID=111"></script>传值,在CommentVote.aspx页面如何得到该值,如何把CommentVote.aspx页面的html代码再返回到index.htm页面

------解决方案--------------------
   <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="CommentVote.aspx?modelID=111">HyperLink</asp:HyperLink>

接收:

string s=  Request.QueryString["modelID"];
    
------解决方案--------------------
引用:
index.htm页面<script type="text/javascript" src="CommentVote.aspx?modelID=111"></script>传值,在CommentVote.aspx页面如何得到该值,如何把CommentVote.aspx页面的html代码再返回到index.htm页面


这是跨域的一种解决方案~但是条件诸多。
你这种使用方式有误的。
------解决方案--------------------
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "CommentVote.aspx?modelID=111";
document.body.appendChild(script);

然后在后台返回的一定要是这样的
var a = "..."
------解决方案--------------------
index.html

<script type="text/javascript" >
function Go()
{
  window.location="CommentVote.aspx?modelID=111";
}
Go();
</script>

然后在CommentVote.aspx页面中这样获取参数:

 string Str=Request.QueryString["modelID"].ToString();

在CommentVote.aspx页面转向index.html:

 Response.Redict("index.html");


------解决方案--------------------
获取参数用Request.QueryString["modelID"]就行了,CommentVote.aspx里返回的数据都将作为Javascript在index.html中被引用(最好放在head中)。
所以CommentVote.aspx里应该直接把默认添加的Xhmtl都去掉,直接写JS(连<script />都不需要了。
也可以用<%Request.QueryString["modelID"]%>写服务端代码,或者在.cs中Response.Write()输出JS

如何返回到index.html?要么你在CommentVote.aspx中输出JS对象,比如文本或者Json对象,然后在index.html中调用函数,或者直接给到某个html控件上