使用表单和POST方法通过Javascript获取URL参数 [英] Using forms and POST method to get URL parameters through Javascript

查看:103
本文介绍了使用表单和POST方法通过Javascript获取URL参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,假设有一个URL http://example.com/index.html/hello/嗨其中你好"和嗨"是参数.

So let's say there's a URL http://example.com/index.html/hello/hi where "hello" and "hi" are parameters.

您将如何使用javascript和表单方法POST提取参数?

How would you use javascript and forms method POST to extract the parameters?

推荐答案

这可能有效...

var secondvar = window.location.href.split('/')[window.location.href.split('/').length];
var firstvar = window.location.href.split('/')[window.location.href.split('/').length-1];

这篇关于使用表单和POST方法通过Javascript获取URL参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆