zoukankan      html  css  js  c++  java
  • 使用Jquery向一个空白网页动态创建一个iframe,及嵌入页面,和向嵌入页面传参

    [csharp] view plaincopyprint?
    using Microsoft.VisualBasic;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Diagnostics;
    using System.Collections.Specialized;
    using Microsoft.JScript;
    namespace MCS
    {
    public partial class MyDialog : System.Web.UI.Page
    {
    protected string strParam = null;
    private void Page_Load(System.Object sender, System.EventArgs e)
    {

    }

    public string GetParam()
    {
    strParam = string.Empty;
    int loop1 = 0;
    int loop2 = 0;
    string[] arr1 = null;
    string[] arr2 = null;
    NameValueCollection coll = null;

    //Load Form variables into NameValueCollection variable.
    coll = Request.QueryString;
    //Get Names of all keys into a string array.
    arr1 = coll.AllKeys;
    for (loop1 = 0; loop1 <= arr1.GetUpperBound(0); loop1++)
    {
    strParam = strParam + arr1[loop1] + "=";
    // Get all values under this key.
    arr2 = coll.GetValues(loop1);
    for (loop2 = 0; loop2 <= arr2.GetUpperBound(0); loop2++)
    {
    if (Information.IsDate(arr2[loop2]))
    arr2[loop2] = DateTime.Parse(arr2[loop2]).ToString("MM/dd/yyyy hh:mm:ss tt");

    strParam = strParam + arr2[loop2] + "&";
    }
    }

    if (strParam.Length > 0 && strParam.Contains("&"))
    strParam = strParam.TrimEnd('&');
    return strParam;
    }

    public string GetPage()
    {
    return Request.QueryString["Page"];
    }
    }
    }
    以上GetPage方法得到iframe里嵌入的页面,GetParam方法则是得到要传递的参数
    下面是前台Jquery页面
    [csharp] view plaincopyprint?
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyDialog.aspx.cs" Inherits="MCS.MyDialog" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title>Dialog</title>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
    $(document).ready(function () {
    var if_w = $("body").width();
    var if_h = $(window).height();
    $("<iframe width='" + if_w + "' height='" + if_h + "' id='Frame1'></iframe>").prependTo('body');
    $("#Frame1").attr("src", "<%= GetPage() %>" + "?" + unescape("<%= GetParam() %>"));
    });
    </script>
    </head>
    <body>
    </body>
    </html>
    至于为什么要放在iframe里面,而不直接使用load方法,是为了防止跳转时弹出一个新页面,而不是在本页面中跳转

  • 相关阅读:
    每日英语:Easing Gaokao Restrictions: a New Year's Gift?
    每日英语:Targeting Grandpa: China’s Seniors Hunger for Ads
    每日英语:Eight Questions: Bianca Bosker on China's 'Original Copies' in Architecture
    每日英语:There's No Avoiding Google+
    如何删除控制面板中没有"删除"菜单的程序
    html中利用javascript实现文本框字数的动态计算
    一条批处理语句ping局域网内的所有机器
    javascript中的"+"运算
    在asp.net中使用分帧页面时,ajax control报access denied错误的解决方法
    gridview和repeater中取得行的序号
  • 原文地址:https://www.cnblogs.com/xdot/p/5028784.html
Copyright © 2011-2022 走看看