首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

<script type="text/javascript" src="CommentVote.aspx?modelID=1

2013-07-01 
script typetext/javascript srcCommentVote.aspx?modelID111/script传值问题index.htm页面sc

<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控件上



function myReturn(){
  document.getElementById("txt_name").value = "指定的值";
}

在index.html中,直接调用myReturn()就好了,你还可以带参数。
或者利用Ajax异步调用

[解决办法]
取值会了啊

LZ是不是想做类似点击数的功能啊
index.htm页面<script type="text/javascript" src="CommentVote.aspx?modelID=111"></script>
就只留下这一句话别的删除看看呢


[解决办法]
其实你那个应该是弄错了。想传数到另一个页面(例如a.aspx),要么就是
服务器端用:response.redirect("a.aspx?name=xxx");
客户端用:window.locatioin.href("a.aspx?name=xxx");
接收的话就是:string a=Request.QueryString["name"];
客户端跟服务器端还是有一点点差别的;你可以再后面加上一个
Response.write("<script>alert("a")</script>");试试效果就知道了;
我可是纯手工打出来的哦!楼主觉得好的话,记得给我分哦!
[解决办法]

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

 CommentVote.aspx这个页面这样输出就行了:

Response.Write("document.write('" + voteNumber + "');");

还有就是index.html引用时最好加charset="gb2312",<script type="text/javascript" src="CommentVote.aspx?modelID=111" charset="gb2312">

热点排行