最近遇到的项目总是习惯左边一个树,点击每个树的节点右边出现相应的信息,遇到这种情况用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>
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 });
传递到该页面后,接收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 }
时间: 2024-10-28 05:01:53