Js
2015-07-18 17:31
579 查看
1. 关闭当前窗口
<a href="javascript:window.opener=window.self;window.close()"></a>2. 验证可以输入多少个汉字(下面表示输入的汉字大于20个)
str.replace(/[^\x00-\xff]/g,'xx').length > 50//把原本录入是换行的展示时也换行
var specialRequireVal = (result[i]["value"]).replace(/\n/g,"<BR>");
<% request.setAttribute("vEnter", "\n"); %>
${fn:replace(item.value,vEnter,"<BR>") }
cellTd.style.textAlign="left";
//验证是否有中文
function isChiness(str){
if(/.*[\u4e00-\u9fa5]+.*$/.test(str)) {
//alert("不能含有中文!");
return false;
}
return true;
}
function IE_Flash()
{
try
{
var swf=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
alert("已安装插件");
}
catch(e)
{
alert("没有安装插件");
}
}
//FireFox,Chrome中判断是否安装插件
function FF_or_Chrome_Flash()
{
var swf=navigator.plugins["Shockwave Flash"];
(swf)?alert("已安装插件"):alert("没有安装插件");
}
//js定位到页面的某个锚点
location.hash="maoDian";
window.location
属性 描述
hash 设置或获取 href 属性中在井号“#”后面的分段。
host 设置或获取 location 或 URL 的 hostname 和 port 号码。
hostname 设置或获取 location 或 URL 的主机名称部分。
href 设置或获取整个 URL 为字符串。
pathname 设置或获取对象指定的文件名或路径。
port 设置或获取与 URL 关联的端口号码。
protocol 设置或获取 URL 的协议部分。
search 设置或获取 href 属性中跟在问号后面的部分。
_value = _value.htmlEncode();
_value = _value.replace(/ /g, " "); //页面显示的时候把空格也显示出来
$("#bag option").each(function(){
if($(this).text()=="xxx"){
$(this).attr("selected",true)
//$(this).attr("selected","selected")两者都可以选中
}
// 中文字两个字节
jQuery.validator.addMethod(
"byteRangeLength",
function(value, element, param) {
var length = value.length;
for(var i = 0; i < value.length; i++){
if(value.charCodeAt(i) > 127){
length++;
}
}
return this.optional(element) || (length >= param[0] && length <= param[1]);
},
$.validator.format("请确保输入的值在{0}-{1}个字节之间(一个中文字算2个字节)")
);
// 邮政编码验证
jQuery.validator.addMethod("isZipCode", function(value, element) {
var tel = /^[0-9]{6}$/;
return this.optional(element) || (tel.test(value));
}, "请正确填写您的邮政编码");
window.onload = function () {
$("#main").css("width", $(window).width() - 210);
$("#main").css("height", $(window).height() - 108);
$("#mainHidder").css("height", $(window).height() - 108);
$("#menu").css("height", $(window).height() - 108);
}
window.onresize = function () {
$("#main").css("width", $(window).width() - 210);
$("#main").css("height", $(window).height() - 108);
$("#mainHidder").css("height", $(window).height() - 108);
$("#menu").css("height", $(window).height() - 108);
}
相关文章推荐
- Javascript 设计模式 辛格尔顿
- BreezeJs用户手册
- BreezeJs使用
- 轉發和重定向-JSP
- JSP实现文件上传,解决上传文件名为乱码问题
- json字符串解析
- JS frame 跨域 传值
- js打印数组,js打印对象的方法
- JS null问题
- 【JavaScript 13—应用总结】:锁屏遮罩
- 【JavaScript 13—应用总结】:锁屏遮罩
- 浏览器调试动态js脚本
- JS刷新验证码
- JavaScript函数
- JavaScript面向对象与原型
- 深入浅出js事件
- javascript实现页面刷新时自动清空表单并选中的方法
- 安卓客户端与jsp互相用json进行数据的传递与解析
- 关于html选择文件(input指定类型js判断)
- JS高级程序设计11-DOM扩展