取出js方法传入的参数的值

当我点击删除步骤时,我想在ASP.NET的后台里取出[S02]这个ID值!这个ID值是在functionstepContextMenu(stepId,stepType){... 当我点击删除步骤时,我想在ASP.NET的后台里取出[S02]这个ID值! 这个ID 值是在 function stepContextMenu(stepId,stepType){
//菜单源文本
var menuSrc = '<menu><entity id="c0"><description>编辑步骤['+stepId+']</description><image>inc/contextMenu/images/edit_obj.gif</image><fontcolor>'+MenuTextColor_enable+'</fontcolor><onClick>cleancontextMenu();editStep("'+stepId+'","'+stepType+'");</onClick><contents></contents></entity>';
if(stepType!='BeginStep' && stepType!='EndStep') menuSrc+= '<entity id="c1"><description>删除步骤['+stepId+']</description><image>inc/contextMenu/images/del_obj.gif</image><fontcolor>'+MenuTextColor_enable+'</fontcolor><onClick>cleancontextMenu();delStep("'+stepId+'");</onClick><contents></contents></entity>';
menuSrc+= '<entity id="c2"><description>刷新</description><image>inc/contextMenu/images/refresh_vml.gif</image><fontcolor>'+MenuTextColor_enable+'</fontcolor><onClick>cleancontextMenu();redrawVML();</onClick><contents></contents></entity></menu>';
showContextMenu(menuSrc);
}
这个方法里传入的,请高手帮帮我,把stepId 传到一个asp.net的页面上或者后台去!

做出来的再加20分~~~~~
展开
 我来答
萝莉天谲
2015-07-14
知道答主
回答量:93
采纳率:100%
帮助的人:22.3万
展开全部
<Script language="javascript">
function GetRequest() {

var url = location.search; //获取url中"?"符后的字串
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for(var i = 0; i < strs.length; i ++) {
theRequest[strs[i].split("=")[0]]=(strs[i].split("=")[1]);
}
}
return theRequest;
}
</Script>

然后我们通过调用此函数获取对应参数值:
<Script language="javascript">
var Request = new Object();
Request = GetRequest();
var 参数1,参数2,参数3,参数N;
参数1 = Request[''参数1''];
参数2 = Request[''参数2''];
参数3 = Request[''参数3''];
参数N = Request[''参数N''];
</Script>
以此获取url串中所带的同名参数

二、正则分析法。
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");
var r = window.location.search.substr(1).match(reg);
if (r!=null) return (r[2]); return null;
}
alert(GetQueryString("参数名1"));
alert(GetQueryString("参数名2"));
alert(GetQueryString("参数名3"));

其他参数获取介绍:
//设置或获取对象指定的文件名或路径。
alert(window.location.pathname);

//设置或获取整个 URL 为字符串。
alert(window.location.href);

//设置或获取与 URL 关联的端口号码。
alert(window.location.port);

//设置或获取 URL 的协议部分。
alert(window.location.protocol);

//设置或获取 href 属性中在井号“#”后面的分段。
alert(window.location.hash);

//设置或获取 location 或 URL 的 hostname 和 port 号码。
alert(window.location.host);

//设置或获取 href 属性中跟在问号后面的部分。
alert(window.location.search);
植下琪大教
2010-04-01 · TA获得超过217个赞
知道小有建树答主
回答量:121
采纳率:0%
帮助的人:77.8万
展开全部
传到后台去比较麻烦,理论上js是客户端语言,不可与后台通信,但是你可以使用其他方式变换的传到后台,当然比较麻烦。
我给你说说我的传递到另外页面的思路,首先确定要传过去的页面是否是这个的父页面,如果不是它的父页面,那么只能通过链接地址传递了。
如果是父页面那就简单了,给接收的父页面建立一个隐藏帧,然后该页面在执行stepContextMenu方法时候给父页面的隐藏帧赋值,document.parent.document.getElementById("***").value=stepId
或者父的父document.parent.parent.document.getElementById("***").value=stepId
等等,这样父就可拿到最新的这个id
同样你如果要传到后台,那么就需要有表单提交,可以吧这个stepId动态放到提交的表单中,然后传递到后台request接收。

当然上面也说了,单独js是无法和后台通信的
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式