HTML SAMPLE: 字体上移下移 + 禁止右键 + 判断浏览器

<div>
	<a href="http://www.baidu.com"	οnclick="javascript:alert('baidu')">百度</a>
	Java<font size="-1"><sup>TM</sup></font> programming language.<br/>
	Java<font size="-6">TM</font> programming language.
</div>

 

判断浏览器

<SCRIPT language="javascript">
    function catchRightClick(e){
        if(navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)){
            alert("You are not allowed to right click");
            return false;
        } else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 3 || event.button == 2)){
            alert("You are not allowed to right click");
            return false;
        }
        return true;
    }

 

    
<%-- start 090923 --%>
	function setElementDisplay(id, op){
	  var obj=document.getElementById(id);
	  obj.style.display = op;
	}
	
	function showElementByTime(id, time, display) {
	  if (display == undefined) {
	    display = 'block';
	  }
	  var s = "setElementDisplay('"+ id +"','"+ display +"')";
	  setTimeout(s, time);
	}
	
	function hideElementByTime(id, time) {
	  var s = "setElementDisplay('"+ id +"','none')";
	  setTimeout(s, time);
	}
	
	function appendHTML(id, html) {
	  document.getElementById(id).innerHTML += html;  
	}
<%-- end 090923 --%>   
    document.οnmοusedοwn=catchRightClick;
    document.οnmοuseup=catchRightClick;
    if(document.layers)
    	window.captureEvents(Event.MOUSEDOWN);
    if(document.layers)
    	window.captureEvents(Event.MOUSEUP);
    
    window.οnmοusedοwn=catchRightClick;
    window.οnmοuseup=catchRightClick; 
</SCRIPT>

 

 

table宽度布局

<table>
    <colgroup width="20%"></colgroup>
    <colgroup width="30%"></colgroup>
    <colgroup width="30%"></colgroup>
    <colgroup width="20%"></colgroup>
    <tr><td></td></tr>
</table>
 
java 获取各种时间: 年月日时分秒
Calendar cal = Calendar.getInstance();
cal.setTime(criteriaHK.getToDate());
cal.add(Calendar.HOUR, 23);
cal.add(Calendar.MINUTE, 59);
cal.add(Calendar.SECOND, 59);
criteriaHK.setToDate(cal.getTime());
 
 操作checkbox
function setKeywordSearchCheckboxes() {
	if ('Y' == '<%=keywordSearch%>') {
      var checkboxArr = document.getElementsByName("<%=CustomerSearchPage.KEYWORD_SEARCH_CHECKBOX%>");
      if (checkboxArr.length > 0) {
        for (var i=0; i<checkboxArr.length; i++) {
          checkboxArr[i].checked = true;
         }
         setKeywordSearch(checkboxArr[0]);
       }
    }
}
 
 java script 处理jsp请求
//--------------------------------------------------------------

<SCRIPT language="javascript">
function perform(action, row){
<%@ include file="../common_perform.jsp"%>
    if(action=="<%=AloginPageNames.ALOGIN_AW001_01_GO%>") {
       gotoPage('<%=AloginPageNames.ALOGIN_AW001_01_GO%>');
       showProgress();
    } else if(action=="cancel"){
       document.theForm.reset();
    }
}
</SCRIPT>
//--------------------------------------------------------------
function gotoPage(page, anchor) {
    document.theForm.action = "<%=Text.get("front_controller")%>?" + "action="+page;
    if (anchor != null) {
        document.theForm.action += appendBrowserTimeInfo() + "#" + anchor;
    } else {
        document.theForm.action += appendBrowserTimeInfo();
    }
    document.theForm.submit();
    submitTime = new Date().getTime();
}
 
// 获取客户端的时间
//--------------------------------------------------------------
<script language="javascript">

  var browserEndTime=null;

/*
  Purpose: 
  Get the current time of client machine.

  Returns:
  client date & time in format dd-mm-yyyy|hh:mm:ss:ff
*/
function getBrowserTime() {
	var gettme = new Date().getTime();
  var currDay = new Date();
  var currYear = currDay.getFullYear();
  var currMonth = currDay.getMonth() + 1;
  var currDate = currDay.getDate();
  var currHours = currDay.getHours();
  var currMinutes = currDay.getMinutes();
  var currSeconds = currDay.getSeconds();
  var currMilliSeconds = currDay.getMilliseconds();
  var clientTime = padLeadingZeros(currDate,2)+"-"+padLeadingZeros(currMonth,2)+"-"+currYear+"|"+padLeadingZeros(currHours,2)+":"+padLeadingZeros(currMinutes,2)+":"+padLeadingZeros(currSeconds,2)+":"+padLeadingZeros(currMilliSeconds,3);	
  return clientTime;
}
//--------------------------------------------------------------
/*
  Purpose: 
  Pad leading zero to fit with the date and time format in log file.

  Parameters:
  inValue  - date and time value returned from new Date()
  inLength - the length required for log format

  Returns:
  client time
*/
function padLeadingZeros(inValue, inLength) {
  var returnValue = ""+inValue;
  while (returnValue.length < inLength) {    
    returnValue = "0"+returnValue;
  }
  return returnValue;
}
--------------------------------------------------------------
/*
  Purpose: 
  For appending client_begin_time, pre_action and client_end_time to the original url.

  Returns:
  String with client_begin_time, pre_action and client_end_time
*/
<%@ page import="manulife.common.view.HtmlEncoder"%>
function appendBrowserTimeInfo() {
  if (!<%=LoggerAdapter.out.enableClientTimeMeasurement()%>) return "";

  var url = "&client_begin_time="+getBrowserTime();
  if (browserEndTime != null && '<%=HtmlEncoder.filterXssCharacters(request.getParameter("client_begin_time"))%>' != 'null') {
    url += "&pre_action="+'<%=HtmlEncoder.filterXssCharacters(request.getParameter("action"))%>'+"&client_end_time="+browserEndTime;
  }
  return url;
}
</script>
 
安全考虑: 去除输入的危险字符
public class HtmlEncoder {
    public static String filterXssCharacters(String inStr) {
        if (inStr != null) {
            // "<",">","=","&#60;","&#61;","&#62;"
            inStr = inStr.replaceAll("<","");
            inStr = inStr.replaceAll(">","");
            inStr = inStr.replaceAll("=","");
            inStr = inStr.replaceAll("&#60;","");
            inStr = inStr.replaceAll("&#61;","");
            inStr = inStr.replaceAll("&#62;","");
            inStr = inStr.replaceAll("[{]","");
            inStr = inStr.replaceAll("}","");
            inStr = inStr.replaceAll("//","");
            inStr = inStr.replaceAll(";","");
            inStr = inStr.replaceAll("&#123;","");
            inStr = inStr.replaceAll("&#125;","");
            inStr = inStr.replaceAll("&#47;&#47;","");
            inStr = inStr.replaceAll("&#59;","");
            inStr = inStr.replaceAll("\\(", "");
            inStr = inStr.replaceAll("&#40;", "");
            inStr = inStr.replaceAll("\\)", "");
            inStr = inStr.replaceAll("&#41;", "");
            inStr = inStr.replaceAll("\\|\\|", "");
            inStr = inStr.replaceAll("&#124;&#124;", "");
        }
        return inStr;
    }
}
 
 判断form中的控件的类型 
function hasUserInput(frm) {
    var f = frm.length;
    var inputCount = 0;
    while (f--) {
        if ((frm[f].value != '') && (frm[f].type == "text")) {
            inputCount++;
            break;
        }
    }
    return inputCount;
}
 
 html中的热点 
<FORM name=SubmitForm action="" method=post>
<IMG SRC="eoffer/offer/IFP0100905/images/agent.gif" ALT="" WIDTH=600 HEIGHT=751 border="1" usemap="#Map">
<map name="Map">
  <area shape="rect" coords="88,641,570,665" 
  href="javascript:popupWindowWithSize('/aws/eoffer/offer/images/wpeoffer.pdf','500','400')">
  <area shape="rect" coords="88,675,570,700" 
  href="javascript:popupWindowWithSize('/aws/eoffer/offer/IFP0100905/preview.html','600','400')">
  <area shape="rect" coords="88,708,570,734" 
  href="javascript:submitURL('aws_main.jsp?action=eoffer_aw010_02_select1');showProgress('images/progress.gif');" οnclick="return checkIfSubmitted();">

</map>
</FORM>

 

 

Html 分组上拉框

<select name="city">
                <optgroup label="山东">
                        <option value="1">济南</option>
                        <option value="2">青岛</option>
                        <option value="3">烟台</option>
                </optgroup>
                <optgroup label="北京市">
                        <option value="4">海淀区</option>
                        <option value="5">朝阳区</option>
                </optgroup>
</select>

来源: http://www.myexception.cn/HTML-CSS/965224.html

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值