乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      [JavaScript]window.open的post與get傳遞參數(shù)比較

       WindySky 2009-07-17

      最近剛好有這樣的需求...小弟測試心得分享給大家呀...

      一般利用js的window.open開另一網(wǎng)要傳參數(shù)都用Get..方式..在url後面接參數(shù)...

      但如果傳帳號.密碼..可能會被看到...不安全..去找了一下window.open在post上的用法...

      JScript.js

      1. function openWindowWithPost(url, name, keys, values) {   
      2.     var newWindow = window.open(url, name);   
      3.     if (!newWindow) return false;   
      4.     var html = "";   
      5.     html += "<html><head></head><body><form id='formid' method='post' action='" + url + "'>";   
      6.     if (keys && values && (keys.length == values.length))   
      7.         for (var i = 0; i < keys.length; i++)   
      8.         html += "<input type='hidden' name='" + keys[i] + "' value='" + values[i] + "'/>";   
      9.     html += "</form><script type='text/javascript'>document.getElementById(\"formid\").submit()</script></body></html>";   
      10.     newWindow.document.write(html);   
      11.     return newWindow;   
      12. }  

       

      OpenPost.aspx

      1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="OpenPost.aspx.cs" Inherits="OpenPost" %>  
      2.   
      3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">  
      4. <html xmlns="http://www./1999/xhtml">  
      5. <head runat="server">  
      6.   
      7.     <script src="JScript.js" type="text/javascript"></script>  
      8.   
      9.     <title></title>  
      10. </head>  
      11. <body>  
      12.     <form id="form1" runat="server">  
      13.     <div>  
      14.         <input id="id" type="text" />  
      15.   
      16.         <input id="pwd" type="password" />  
      17.   
      18.         <input id="Button1" type="button" value="Post" onclick="Post();" />  
      19.         <input id="Button2" type="button" value="Get" onclick="Get();" />  
      20.     </div>  
      21.     </form>  
      22. </body>  
      23. </html>  
      24.   
      25. <script type="text/javascript">  
      26.     function Post() {   
      27.         var keys = [];   
      28.         var values = [];   
      29.         keys[0] = "id";   
      30.         keys[1] = "pwd";   
      31.         values[0] = document.getElementById("id").value;   
      32.         values[1] = document.getElementById("pwd").value;   
      33.         openWindowWithPost("result.aspx", "web", keys, values);   
      34.     }   
      35.     function Get() {   
      36.         window.open("result.aspx?id=" + document.getElementById("id").value + "&pwd=" + document.getElementById("pwd").value, "web");   
      37.     }   
      38. </script>  

       

      OpenPost.aspx.cs(省略)

      result.aspx(省略)

      result.aspx.cs

      1. using System;   
      2. using System.Collections.Generic;   
      3. using System.Web;   
      4. using System.Web.UI;   
      5. using System.Web.UI.WebControls;   
      6.   
      7. public partial class result : System.Web.UI.Page   
      8. {   
      9.     protected void Page_Load(object sender, EventArgs e)   
      10.     {   
      11.         if (Request.Form["id"] != null)   
      12.         {   
      13.             Response.Write("id:" + Request.Form["id"].ToString() + "<" + "br/>");   
      14.         }   
      15.   
      16.         if (Request.Form["pwd"] != null)   
      17.         {   
      18.             Response.Write("pwd:" + Request.Form["pwd"].ToString() + "<" + "br/>");   
      19.         }   
      20.   
      21.         if (Request.QueryString["id"] != null)   
      22.         {   
      23.             Response.Write("id:" + Request.QueryString["id"].ToString() + "<" + "br/>");   
      24.         }   
      25.   
      26.         if (Request.QueryString["pwd"] != null)   
      27.         {   
      28.             Response.Write("pwd:" + Request.QueryString["pwd"].ToString() + "<" + "br/>");   
      29.         }   
      30.     }   
      31. }  

       

      執(zhí)行結(jié)果:

      POST結(jié)果:

      GET結(jié)果:

      參考網(wǎng)址:

      http://www./forum/archive/index.php/t-1688.html

        本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多