• js中iframe的用法


    最近遇到的项目总是习惯左边一个树,点击每个树的节点右边出现相应的信息,遇到这种情况用iframe还是很简单的,

    例如 : 页面文件

     1 @section Tree{
     2     <ul id="tree">
     3     </ul>
     4  
     5 }
     6 @section Search
     7 {
     8 }
     9 <input id="clickassets" type="hidden" value="@ViewBag.url" />
    10 <div class="g_tgCenterGrid" data-options="region:'center',border:1" id="dvGrid">    
    11     <iframe marginwidth="0" src="@Url.Content("~/System/MachineConfig")" nodeId="00302" style=" 100%; height: 750px" name="i" id="urlIframe"
    12         frameborder="0" scrolling="no"></iframe>
    13 </div>
    View Code

    js文件

     1    $.ajax({
     2                     dataType: "text",
     3                     url: TY.Root + "System/MachineConfigInfo?RowId=" + nodeid + "&m_name=" + noidtext,
     4                     type: "post",
     5                     success: function (result) {
     6 
     7                         if (result != null && result != "") {
     8                             var da = result.split(",");
     9                             var me = this;
    10                             $("#dvGrid").html("<iframe marginwidth='0' src='MachineConfig?nodeId=" + da[0] + ',' + da[1] + '&RowId=' + da[0] + '&m_name=' + da[1] + "' style=' 100%; height: 750px' name='i' id='urlIframe' frameborder='0' scrolling='no'></iframe>");
    11 
    12                         }
    13                     }
    14 
    15                 });
    View Code

    传递到该页面后,接收iframe传递过来的参数

     1       if (location.href.indexOf("?nodeId=") > -1) {
     2                 var ids = request('nodeId');
     3                 var da = ids.split(",");
     4                      }
     5 
     6 
     7 
     8 //获取url的参数
     9         function request(strParame) {
    10             var args = new Object();
    11             var query = location.search.substring(1);
    12 
    13             var pairs = query.split("?"); // Break at ampersand 
    14             for (var i = 0; i < pairs.length; i++) {
    15                 var pos = pairs[i].indexOf('=');
    16                 if (pos == -1) continue;
    17                 var argname = pairs[i].substring(0, pos);
    18                 var value = pairs[i].substring(pos + 1);
    19                 value = decodeURIComponent(value);
    20                 args[argname] = value;
    21             }
    22             return args[strParame];
    23         }
    View Code
  • 相关阅读:
    预处理器&预处理变量&头文件保护&条件编译
    Xctf攻防世界—crypto—Normal_RSA
    RSA共模攻击
    centos7安装宝塔面板
    cobalt strike出现连接超时情况解决办法
    C语言变量
    Hello World!
    ctfshow—web—web7
    ctfshow—web—web6
    ctfshow—web—web5
  • 原文地址:https://www.cnblogs.com/wsl2011/p/4193936.html
Copyright © 2020-2023  润新知