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="width: 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='width: 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

 

转载于:https://www.cnblogs.com/wsl2011/p/4193936.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值