最近因为要演示,做个临时ifame框架页面,因此子页面要根据父页面url来指定跳转。下面为ifame页面:
1、获取子页面url:
var currentpath = window.location.pathname;
console.log(currentpath);
输出为:/JG/TJ_JILU.aspx
2、获取父页面url:
let currentTopHref = window.top.location.href;
console.log(currentTopHref);
输出为:http://localhost:16796/indexjg1.aspx?lx=12&appname=123
3、获取子页面参数:
var params = location.search;
console.log(params);
输出为:?zhcx=1&LX_CODE=Y05&STATUS_FLAG=1&year=2022 (注:从问号开始)
有了以上值,再判断下跳转即可:
//如果父框架是indexjg1.aspx,则当前子页面跳转到页面 TJ_JILU1.aspx
if (current