使用Jquery向一个空白网页动态创建一个iframe,及嵌入页面,和向嵌入页面传参
2014-04-30 15:11
861 查看
01.using Microsoft.VisualBasic; 02.using System; 03.using System.Collections; 04.using System.Collections.Generic; 05.using System.Data; 06.using System.Diagnostics; 07.using System.Collections.Specialized; 08.using Microsoft.JScript; 09.namespace MCS 10.{ 11. public partial class MyDialog : System.Web.UI.Page 12. { 13. protected string strParam = null; 14. private void Page_Load(System.Object sender, System.EventArgs e) 15. { 16. 17. } 18. 19. public string GetParam() 20. { 21. strParam = string.Empty; 22. int loop1 = 0; 23. int loop2 = 0; 24. string[] arr1 = null; 25. string[] arr2 = null; 26. NameValueCollection coll = null; 27. 28. //Load Form variables into NameValueCollection variable. 29. coll = Request.QueryString; 30. //Get Names of all keys into a string array. 31. arr1 = coll.AllKeys; 32. for (loop1 = 0; loop1 <= arr1.GetUpperBound(0); loop1++) 33. { 34. strParam = strParam + arr1[loop1] + "="; 35. // Get all values under this key. 36. arr2 = coll.GetValues(loop1); 37. for (loop2 = 0; loop2 <= arr2.GetUpperBound(0); loop2++) 38. { 39. if (Information.IsDate(arr2[loop2])) 40. arr2[loop2] = DateTime.Parse(arr2[loop2]).ToString("MM/dd/yyyy hh:mm:ss tt"); 41. 42. strParam = strParam + arr2[loop2] + "&"; 43. } 44. } 45. 46. if (strParam.Length > 0 && strParam.Contains("&")) 47. strParam = strParam.TrimEnd('&'); 48. return strParam; 49. } 50. 51. public string GetPage() 52. { 53. return Request.QueryString["Page"]; 54. } 55. } 56.}
01.<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyDialog.aspx.cs" Inherits="MCS.MyDialog" %> 02. 03.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 04.<html xmlns="http://www.w3.org/1999/xhtml"> 05.<head runat="server"> 06. <title>Dialog</title> 07. <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> 08. <script type="text/javascript" language="javascript"> 09. $(document).ready(function () { 10. var if_w = $("body").width(); 11. var if_h = $(window).height(); 12. $("<iframe width='" + if_w + "' height='" + if_h + "' id='Frame1'></iframe>").prependTo('body'); 13. $("#Frame1").attr("src", "<%= GetPage() %>" + "?" + unescape("<%= GetParam() %>")); 14. }); 15. </script> 16.</head> 17.<body> 18.</body> 19.</html>
至于为什么要放在iframe里面,而不直接使用load方法,是为了防止跳转时弹出一个新页面,而不是在本页面中跳转
相关文章推荐
- 【jQuery学习笔记----AJAX之javascript角度】
- jquery事件
- 企业开发中js,Jquery,Ajax和json格式的一个例子
- JQuery EasyUI 日期控件 控制日期选择区间的方法!
- jQuery EasyUI相关问题
- jQuery操作input值总结
- Permit.js – 用于构建多状态原型的 jQuery 插件
- 自己写了一个无缝滚动的插件(jQuery)
- jquery判断自己是父节点的第几个子节点
- jQuery 菜单栏 展开与收缩例子
- jQuery中.bind() .live() .delegate() .on()的区别
- Jquery jqgrid 在编辑的时候获取文本框里的值
- jquery删除原事件
- jQuery源码分析1
- jquery 选择器
- jQuery autocomplete 组件使用
- jquery mobile-按钮控件
- jQuery操作json数据
- jQuery DataTables Plugin Meets C#
- 基于MVC3下拉列表联动(JQuery)