雜項—-

來源:互聯網
上載者:User

 
技巧1--防止js緩衝 css也可以這樣
<script type="text/javascript" language="javascript" src="../js/Checksfz.js?temp=<%=DateTime.Now.Ticks%>"></script>
******************************
禁止複製,剪下 和右建

oncontextmenu   = " event.returnValue=false "   oncopy  = "event.returnValue=false"  
oncut="event.returnValue=false"

文字框不允許自動記錄
autocomplete="off"
******************************
·超串連樣式
******************************
a:link 指正常的未被訪問過的連結;
a:hover 指滑鼠在連結上;
a:active 指正在點的連結;
a:visited 指已經訪問過的連結。
 
參數設定:
 
text-decoration是文字修飾效果的意思;none參數表示超連結顯示文字不顯示底線;underline參數表示超連結的文字有底線;如果是overline則給超連結顯示文字加上劃線;換成line-through則是給超連結顯示文字加上刪除線;blink則使文字在閃爍。
 
color:blue,color:red等是給連結文字加顏色。
 
還可以添加其他參數,如:
 
font-weight:bold給連結文字加粗;font-size:16pt設定連結文字字型大小;background:#ffd306給連結文字加背景顏色;font-style:italic連結文字傾斜;border-bottom:1px dashed #51bfe0給連結文字加虛線,其中1px是虛線的粗細度,數值越大越粗,dashed表示虛線,#51bfe0是虛線顏色,如果要給連結文字加虛線的話,就不用加底線了。
************************************

·response清除
************************************
           
             Response.Expires = 0; //設定有效時間
             Response.Buffer = true; //使用快取區域
             Response.Clear (); //清除response
             Response.ContentType = "image/png"; //指定它所輸出的類型
             Response.StatusCode = 200;
             Response.End ();
************************************
·webrequest列子
************************************
Response.Clear();

   HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://www1.fx168.com/fxindex/FMonthIndex.aspx?datetime=2007-10-16"); //獲得一個url請求
   HttpWebResponse response = (HttpWebResponse)request.GetResponse();//獲得輸出資料流對象
   Stream resStream = response.GetResponseStream();  //擷取輸出資料流
   byte[] buf = new byte[1024];
   int count = 0;
   while((count=resStream.Read(buf, 0,buf.Length)) > 0)//將流轉換為位元組序列
   {
    Response.Write(System.Text.Encoding.Default.GetString(buf, 0,count).Replace("oncontextmenu=/"return false;/" onselectstart=/"return false;/" oncopy=/"return false;/" oncut=/"return false;/"",""));//列印出位元組流裡面的字元,並替換js指令碼
   }
   resStream.Close();

*****************************

window.open()屬性
****************************

window.open (url,'快顯視窗' height=455, width=655, top=50, left=300, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=yes,charset=utf-8')

****************************

判斷瀏覽器的類型   window.navigator.appName
判斷ie的版本       window.navigator.appVersion
判斷用戶端的解析度 window.screen.height;  window.screen.width;

***************************
所有的表單的值都不可為空 <input onblur="if(this.value.replace(/^/s+|/s+$/g,'')=='')alert('不可為空!')">

1.email的判斷。
      function ismail(mail)
      {
        return(new RegExp(/^/w+((-/w+)|(/./w+))*/@[A-Za-z0-9]+((/.|-)
[A-Za-z0-9]+)*/.[A-Za-z0-9]+$/).test(mail));
      }

 

2.身份證的驗證
      function isIdCardNo(num)
      {
        if (isNaN(num)) {alert("輸入的不是數字!"); return false;}
        var len = num.length, re; 
        if (len == 15)
          re = new RegExp(/^(/d{6})()?(/d{2})(/d{2})(/d{2})(/d{3})$/);
        else if (len == 18)
          re = new RegExp(/^(/d{6})()?(/d{4})(/d{2})(/d{2})(/d{3})(/d)$/);
        else {alert("輸入的數字位元不對!"); return false;}
        var a = num.match(re);
        if (a != null)
        {
          if (len==15)
          {
            var D = new Date("19"+a[3]+"/"+a[4]+"/"+a[5]);
            var B = D.getYear()==a[3]&&(D.getMonth()+1)==a[4]&&
D.getDate()==a[5];
          }
          else
          {
            var D = new Date(a[3]+"/"+a[4]+"/"+a[5]);
            var B = D.getFullYear()==a[3]&&(D.getMonth()+1)==a[4]&&
D.getDate()==a[5];
          }
          if (!B) {alert("輸入的社會安全號碼 "+ a[0] +" 裡出生日期不對!"); return false;}
        }
        return true;
      }

  
3.檔案上傳過程中判斷檔案類型
<input type=file onchange="alert(this.value.match(/^(.*)(/.)(.{1,8})$/)[3])">

4.不斷地清空剪貼簿:
<body onload="setInterval('clipboardData.setData(/'Text/',/'/')',100)">

5.file://window.opener.location.reload();重新整理父視窗 
6.file://window.opener.location="2.htm"//重新導向父視窗到2.htm頁 

7.說明:讓網頁多長時間(秒)重新整理自己,或在多長時間後讓網頁自動連結到其它網頁。
用法:<Meta http-equiv="Refresh" Content="30">
<Meta http-equiv="Refresh" Content="5; Url=http://www.xia8.net">

8.sql求某個月裡的天數
select DAY(dateadd(day,-1,convert(char(07),dateadd(month,1,@date),120)+'-01'))

9.url轉碼
src="Drawing.aspx?Ccoms=<%=Server.UrlEncode(Ccoms)%>"

10.儲存當前網頁的位置
SmartNavigation = true---加在page屬性裡

11.自訂異常類

  public class MyException:ApplicationException

 

    {
           public MyException():base()

           {

           }

           /// <param name="ErrMessage">異常訊息</param>

           public MyException(string Message):base(Message)
           {

               System.Web.HttpContext.Current.Response.Redirect("~/ShowErr.aspx?msg="+Message);

           }

           /// <param name="Message">異常訊息</param>
           /// <param name="InnerException">引起該異常的異常類</param>
           public MyException(string Message,Exception InnerException):base(Message,InnerException)
           {

           }

       }

12.ifream自適宜大小
onload="this.height =  document.frames[0].document.body.scrollHeight"

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.