使用Jquery向一个空白网页动态创建一个iframe,及嵌入页面,和向嵌入页面传参

14 篇文章 0 订阅
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方法,是为了防止跳转时弹出一个新页面,而不是在本页面中跳转
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值