内嵌iframe

 

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="WapReport.Index" %>
<html>
<head runat="server">
    <title></title>
    <script type="text/javascript">
        //** iframe自动适应页面 **// 
        //输入你希望根据页面高度自动调整高度的iframe的名称的列表 
        //用逗号把每个iframe的ID分隔. 例如: ["myframe1", "myframe2"],可以只有一个窗体,则不用逗号。 
        //定义iframe的ID
        var iframeids = ["frame_main"]
        //如果用户的浏览器不支持iframe是否将iframe隐藏 yes 表示隐藏,no表示不隐藏 
        var iframehide = "yes"
        function dyniframesize() {
            var dyniframe = new Array()
            for (i = 0; i < iframeids.length; i++) {
                if (document.getElementById) {
                    //自动调整iframe高度 
                    dyniframe[dyniframe.length] = document.getElementById(iframeids);
                    if (dyniframe && !window.opera) {
                        dyniframe.style.display = "block"
                        if (dyniframe.contentDocument && dyniframe.contentDocument.body.offsetHeight) //如果用户的浏览器是NetScape 
                            dyniframe.height = dyniframe.contentDocument.body.offsetHeight;
                        else if (dyniframe.Document && dyniframe.Document.body.scrollHeight) //如果用户的浏览器是IE 
                            dyniframe.height = dyniframe.Document.body.scrollHeight;
                    }
                }
                //根据设定的参数来处理不支持iframe的浏览器的显示问题 
                if ((document.all || document.getElementById) && iframehide == "no") {
                    var tempobj = document.all ? document.all[iframeids] : document.getElementById(iframeids)
                    tempobj.style.display = "block"
                }
            }
        }
        if (window.addEventListener)
            window.addEventListener("load", dyniframesize, false)
        else if (window.attachEvent)
            window.attachEvent("onload", dyniframesize)
        else
            window.onload = dyniframesize 
</script> 
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var url = $("#hid_url").val();
            $("#frame_main").attr("src", url);

        });
    
    </script>
</head>
<body>
<form action="/" runat="server" method="post">
   
<iframe  id="frame_main" src="/"; width="100%" height="97%" scrolling="auto" frameborder="0"></iframe>

 </form>
 <input type="hidden" runat="server" id="hid_url" />
  <input type="hidden" runat="server" id="hid_username" />
</body>
</html>

 

后台事件

    try
    {
        string url = Request.QueryString["url"].ToString().Trim();
        this.hid_url.Value = Base64Helper.Decode(url);
        //aHR0cDovLzE5Mi4xNjguMTAxLjIwMi93aXRib29rL2JpbmdrdW4vaW5kZXguYXNw
        // this.hid_url.Value = "http://192.168.101.202/witbook/bingkun/index.asp";
        this.hid_username.Value = "admin";
    }
    catch (Exception)
    {
        this.hid_url.Value = "About.aspx";
                       
    }

 

生成工具:

  <form id="form1" runat="server">
    <div>
      网站原链接:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br />
          <br />
       加密后连接:<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
          <br />
            <br />
        <asp:Button ID="Button1" runat="server" Text="生成地址" onclick="Button1_Click" /> &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp;
        <asp:Button ID="Button2" runat="server" Text="访问地址" onclick="Button2_Click" />
        
    </div>
    </form>

 

后台事件

        protected void Button1_Click(object sender, EventArgs e)
        {
            string url = TextBox1.Text.Trim();
            string decodeUrl = Base64Helper.Encode(url);

            TextBox2.Text = decodeUrl;
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            if (TextBox2.Text.Trim()!="")
            {
                string decodeUrl = TextBox2.Text.Trim();

                Response.Redirect("Index.aspx?url=" + decodeUrl);
            }
        }

 

posted @ 2015-07-14 14:26  兴想事成  阅读(366)  评论(0编辑  收藏  举报