当前位置:网站首页>js页面的跳转以及接收参数
js页面的跳转以及接收参数
2022-07-21 05:05:00 【李子菜】
window.location.href='../yemian/video.html?courseID='+obj;
//获取页面参数开始
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;
}
//首先执行方法,调用getrequest方法,接收参数,处理?后的数据
$(function() {
GetRequest();
var Request = new Object();
Request = GetRequest();
var courseTypeId;
courseTypeId = Request['courseTypeId'];
if(courseTypeId==null){
$.ajax({
type: "POST",
url: "shuju.json", //地址,就是json文件的请求路径
dataType: "json",
async: false,
success: function(result) {
nav_show(result);
course_show(result);
},
error: function(result) {
alert("错误");
}
});
}else{
selectByCourseTypeId(courseTypeId);
}
});
//获取页面参数
//获取页面参数(可识别中文)
function getUrlParam(key) {
// 获取参数
var url = window.location.search;
// 正则筛选地址栏
var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
// 匹配目标参数
var result = url.substr(1).match(reg);
//返回参数值
return result ? decodeURIComponent(result[2]) : null;
}
获取地址中的中文
边栏推荐
- [C language] please fly the detailed ability functions and arrays back to the country of light
- Read the manuscript in pieces
- Detailed derivation of Differential Flatness of UAV
- 让代码解决《线性代数》系列 - 求多项式的最大公因式
- 1020月饼
- Fifth Bureau akali teaching Bureau
- Small game items - Gobang game
- moment自定义时间区间
- Understand the three mountains of JS
- 20.【char*与string相等不相等】
猜你喜欢
随机推荐
In depth analysis of string -- strcpy & strncpy
D. Insert a progression (Mathematics)
Deep analysis of string -- strlen & strtok
深度剖析 —— 数据
碎碎念 碎碎念 起稿
In depth analysis - Data
[C语言] 平淡的日子里泛起光 初阶最后的战役
1014福爾摩斯約會
深度理解指针(冒泡排序模拟实现qsort,函数指针实现回调函数)
模拟实现字符串函数和内存函数(strlen,strcpy,strstr,memcpy.....)
动态监听DOM元素的高度
Read the manuscript in pieces
深度剖析 —— 递归
Acwing 175 circuit maintenance
再见了,各位(虽然没人会注意到)
MySQL之函数
In the fourth game, where is the restaurant? Shepherd boy points to Xinghua village
1009 irony
In depth analysis - structure
[recursive] Ackerman function