码迷,mamicode.com
首页 > Web开发 > 详细

js中iframe的用法

时间:2014-12-30 18:37:41      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:

最近遇到的项目总是习惯左边一个树,点击每个树的节点右边出现相应的信息,遇到这种情况用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

 

js中iframe的用法

标签:

原文地址:http://www.cnblogs.com/wsl2011/p/4193936.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!