zoukankan      html  css  js  c++  java
  • 页面被iframe与无刷新更换url方法

    1. 页面被iframe问题解决方法

       if (window.top.location !== window.self.location) {
               const data = JSON.stringify({ iframedRedirectSuccess: true });
               window.top.location.href = addURLParam(window.self.location.href, 'data', data);
             }
      
    2. 页面初始化获取参数

       import URL from 'url-parse';
       const {
           origin, protocol, host, hostname, port, query, hash,
         } = new URL(document.URL, true);
       
         const hostInfo = {
           origin, protocol, host, hostname, port, query, hash,
         };
      
    3. 页面无刷新删除url上参数(仅适用于无跨域更换url及参数)

        import qs from 'querystringify';
        import omit from 'lodash/omit';
        const param = omit(qs.parse(window.location.search), ['data']);
           const paramStr = qs.stringify(param, '?');
           const url = `${window.location.pathname}${paramStr}`;
           // This is for firefox will reload previous url when we click refresh button or press F5
           // after we use replaceState to replace a new url issue.
           window.location.hash = window.location.hash; // eslint-disable-line 
           window.history.replaceState && window.history.replaceState({}, null, url);
  • 相关阅读:
    jquery扩展
    [转][C#]加密解密类
    [转][C#]压缩解压
    [转][C#]程序的动态编译
    [转][C#]Linq 的扩展方法
    [转]Oracle left join right join
    [转]检测到有潜在危险的 Request.Form 值
    IIS 添加 MIME
    [转][Echarts]俄罗斯方块
    01-python爬虫之常见的加密方式
  • 原文地址:https://www.cnblogs.com/weilantiankong/p/11435976.html
Copyright © 2011-2022 走看看