`
wrean2013
  • 浏览: 3900 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

JSJS

 
阅读更多
js没加var会默认为全局变量,
<script>
var name = "Kevin";
function callName(){
   //alert(name);//1
   var name = "marry";
   //alert(name);//2
}
callName();
</script>
1.弹出undefined
2.弹出marry
猜想:如果有局部变量会先找局部变量,因为找不到还没执行到,所以弹出undefined

所谓的命名空间,其实都是按照window的方式往下扩展而已,window是个对象,window.alert(),window.document其中window可以写,那么我再给window扩展一个随便的对象,window['ol'],那么ol就作为一个起点对象,依照类似的方式就可以实现类似的锤子似的命名空间,往下扩展就能让一个方法绑定一个类似包的东西,比如ol.load.read=function(){.....},最后这个ol你想换成啥就能换成啥,yuwen=ol,yuwen.load.read=function(){...}
绑定的方法:
ol.pkg=function(arg1,arg2,arg3){
var context,namespace,method;
if(arguments.length==3)
{
context=arg1;
namespace=arg2;
method=arg3;
}else{
context=window;
namespace=arg1;
method=arg2;
}

if (!namespace|| !namespace.length) {
return null
}
var a = namespace.split(".");
for (var c = context, f = 0; f < a["length"]-1; f++) {
c[a[f]] || (c[a[f]] = {});
c = c[a[f]];
}
c=(c[a[a["length"] - 1]] = method||c[a[a["length"] - 1]]||{});
return c;
};



ff不支持outerHTML,IE私有的innerText,outerText,innerHTML是都支持的,innerText可以通过正则替换的方式来得到.replace(/<.+?>/gim,''))
正则里的分组和向后引用,例如,日期写为2000/12/03或2004-12-03,但写成2004/12-03或2004-12/03就不好了,正则的写法:(\d{4})([/,-])(\d{1,2})\2(\d{1,2}),排到第几个就写第几个.


不错的一个网站:http://www.tzwhx.com/newOperate/html/2/22/223/20528.html

创建对象有两种方式:new和大括号.访问属性可以用[]或.用[]的好处是可以使用变量.
有关创建对象:
var person = new Object(); 
person.name = "Miles"; 
person.age = 24; 
person.job = "Software Engineer" 
 
person.sayName = function() { 
    alert(this.name); 
}; 
 
person.sayName();
这种方法有个明显的缺点:使用同一个接口创建很多对象,会产生大量的重复代码
为了解决这个方法,我们可以使用工厂模式的一种变体
    function createPerson(name, age, job) { 
        var o = new Object(); 
        o.name = name; 
        o.age = age; 
        o.job = job; 
        o.sayName = function() { 
            alert(this.name); 
        }; 
        return o; 
    } 
     
    var person1 = createPerson("Miles", 24, "Software Engineer"); 
    var person2 = createPerson("Jenny", 24, "Doctor"); 
     
    person1.sayName();  //"Miles" 
    person2.sayName();  //"Jenny" 
工厂模式虽然解决了创建多个相似对象的问题,但没有解决对象识别的问题(即怎样知道一个对象的类型)
随着js的发展,构造函数模式出现了
function Person(name, age, job) { 
    this.name = name; 
    this.age = age; 
    this.job = job; 
    this.sayName = function() { 
        alert(this.name); 
    }; 

 
var person1 = new Person("Miles", 24, "Software Engineer"); 
var person2 = new Person("Jenny", 24, "Doctor"); 
 
person1.sayName();  //"Miles" 
person2.sayName();  //"Jenny"
构造函数与其他函数的唯一区别,就在于调用他们的方式不同。构造函数也是函数,只要通过new操作符来调用,那它就可以作为构造函数,如果不通过new,它跟普通函数没区别。
    //当作构造函数使用 
    var person = new Person("Miles", 24, "Software Engineer"); 
    person.sayName(); // "Miles" 
    //当作普通函数调用 
    Person("Jenny", 24, "Doctor"); 
    window.sayName(); // "Jenny" 
    //在另一个对象的作用于中调用 
    var o = new Person(); 
    Person.call(o, "Sean", 24, "Engineer"); 
    o.sayName(); // "Sean" 
当在全局作用域中调用一个函数时,this对象总是只想Global对象。
构造函数的缺点就是每个方法都要在每个实例上重新创建一遍。也就是上面的实例中每一个sayName不是同一个Function的实例
    alert(person1.sayName() == person2.sayName()); // false 
然后,创建两个完全同样任务的Function实例没有必要,所以可以通过把函数定义转移到构造函数外部来解决这个问题
    function Person(name, age, job) { 
        this.name = name; 
        this.age = age; 
        this.job = job; 
        this.sayName = sayName; 
    } 
    function sayName() { 
            alert(this.name); 
    } 



http://www.javaeye.com/topic/956642
http://www.javaeye.com/topic/19748
http://bokee.shinylife.net/blog/article.asp?id=455
http://www.neoease.com/javascript-namespace/
http://topic.csdn.net/u/20080508/22/cabb49aa-1fce-4fdb-9d0b-81f8bca3e5ef.html

http://ons.javaeye.com/blog/600836
http://www.blogjava.net/herodby/archive/2006/11/27/83837.html
http://www.zsqz.com/jsbase/suanfa/index.html
wml1.0

创建数组有两种方式:new和[]
创建函数有三种方式funcion aa(),aa=function(){}  new Function(),


有关函数的原型:

每个函数都有一个prototype(原型)属性,这个属性是一个对象,他的用途是包含可以由特定类型的所有实例共享的属性和方法。prototype如果是直接赋值的方式,就没有次序关系了,如果是prototype单独定义的话就存在次序的关系了,定义在前,使用在后.通过isPrototypeOf()方法来确定对象之间是否存在关系,当代码读取对象的属性时,先从实例搜索,找到返回,如果没有再从原型中搜索,找到返回。
    var person=function(){
   
    }
    var per1=new person();//都有值不报错
    var per2=new person();//都有值不报错
   
    alert(per1.age==per2.age);//true
   
    person.prototype.name="yuwen";
    person.prototype.age=24;
    person.prototype.sayname=function(){
    alert(this.name);
    };

   alert(person.prototype.isPrototypeOf(per1));
   
    var person2=function(){
    }
    var per22=new person2();//1 空值
    per22.sayname();//报错
    person2.prototype={
    name:'hello',
    age:24,
        sayname:function(){
       alert('woainima');
        }
    };
    var per11=new person2();//2 //都有值不报错
    per11.sayname();//都有值不报错
    var per222=new person2();//3 //都有值不报错

    per2['name']='haha';
    alert(per2['name']);//haha
    delete per2.name;
    alert(per2['name']);//yuwen

感觉上原型就类似与JAVA中的构造函数
原型的作用之一就是扩展原有函数的功能,还有个就是实现函数之间的继承,
    function SuperType() { 
        this.property = true; 
    } 
     
    SuperType.prototype.getSuperValue = function () { 
        return this.property; 
    } 
     
    function SubType() { 
        this.subproperty = false; 
    } 
     
    SubType.prototype = new SuperType(); 
     
    SubType.prototype.getSubValue = function() { 
        return this.subproperty; 
    } 
    var instance = new SubType(); 
    alert(instance.getSuperValue()); // true 
     
    alert(instance instanceof Object); // true 
    alert(instance instanceof SuperType); // true 
    alert(instance instanceof SubType); // true 
     
    alert(Object.prototype.isPrototypeOf(instance)); // true 
    alert(SuperType.prototype.isPrototypeOf(instance)); // true 
    alert(SubType.prototype.isPrototypeOf(instance)); // true 


实现的本质是重写原型对象,代之以一个新类型的实例。给原型添加方法的代码一定要放在替换原型的语句之后,在通过原型链实现继承时,不能使用对象字面量创建原型方法,因为这样就会重写原型链。
通过原型来实现继承时,原型实际上会变成另一个类型的实例,实例会恭喜。而且在创建子类型的时候,不能向超类型的构造函数传递参数。
使用使用一种叫做借用构造函数的技术,解决了原型中包含引用类型值所带来问题。

    function SuperType(name) { 
        this.colors = ["red", "green", "blue"]; 
        this.name = name; 
    } 
    function SubType() { 
        // 继承了SuperTyle, 同时还传递了参数 
        SuperType.call(this, "Miles"); 
        this.age = 24; 
    } 
     
    var instance1 = new SubType(); 
    instance1.colors.push("black"); 
    alert(instance1.colors); //  "red,green,blue,black" 
    alert(instance1.name); // "Miles" 
    alert(instance1.age); //  24 
     
    var instance2 = new SubType(); 
    alert(instance2.colors); // "red,green,blue" 

借用构造函数的方法都在构造函数中定义,因此函数的复用的问题没法解决。
组合继承,指的是讲原型链和借用构造函数的技术组合到一起,使用原型链实现对原型属性和方法的继承,而通过借用构造函数来实现对实例属性的继承。
    function SuperType(name) { 
        this.colors = ["red", "blue", "green"]; 
        this.name = name; 
    } 
     
    SuperType.prototype.sayName = function() { 
        alert(this.name); 
    } 
    function SubType(name, age) { 
        // 继承了SuperTyle, 同时还传递了参数 
        SuperType.call(this, name); 
        this.age = age; 
    } 
     
    SubType.prototype = new SuperType(); 
    SubType.prototype.sayAge = function() { 
        alert(this.age); 
    } 
    var instance1 = new SubType("Miles", 24); 
    instance1.colors.push("black"); 
    alert(instance1.colors); //  "red,blue,green,black" 
    instance1.sayName(); // "Miles" 
    instance1.sayAge();  // 24 
     
    var instance2 = new SubType("Jenny", 24); 
    alert(instance2.colors); // "red,blue,green" 
    instance2.sayName(); // "Jenny" 
    instance2.sayAge();  // 24 

Array的push
delete


{}.constructor会报错,function(){}()会报错,[].construtor不会报错,var c={}.constructor不会报错是因为"js的语句优先"在作怪,JS中大括号的四种用法:1.复合语句,2.对象直接量3,函数声明,4,异常处理语法符号,{}会首先被被理解成复合语句.所以{}.construtcor报错,function(){}()也被理解成复合语句,var c={}.constructor相当于function c(){}.constructor,不会报错,[]不存在那样的问题,修改方式就是加括号,({}).constructor,(function(){}).constructor.


使用初始化的方式来完成JS变量类型的判断/



linux

这周JS(book).JQUERY相关,JFORM,AJAX等,JSAPI那么多.JS除错分析,公司审核改写.CSS.卓博网中有关JS的框架的地方,个人简历,企业会员中心,有关一些页面技巧.


JAVA,jsp,servlet,javamail,jstl,xml解析,ejb,搜索引擎,swing,开源代码的看,协议,木马病毒原理

数据库,索引,存储过程,视图,权限,切分,性能优化SQLSERVER,MYSQL的精通

其他,一些工具,powerdesigner rose等

数据结构,编译原理,计算机组成,OS,

String[] ComIdArr = request.getParameterValues("ComId");

属性是属性,在style里的都是css

disabled提交不上去?
//创建的没勾上

a:link {color: #000; text-decoration:none;}
a:visited {color: #000;text-decoration:none;}
a:hover {color: #bc2931; text-decoration:underline;}
a:active {color: #000;}



创建form的方式提交:
  function createSubmitForm()
  {
    var submitForm = document.createElement("FORM");
    document.body.appendChild(submitForm);
    submitForm.method = "POST";
    submitForm.name="temp_form";
    submitForm.action="chk_cominfo_sev.jsp"
    return submitForm;
  }
function createNewFormElement(inputForm, elementName,elementType,elementValue)
{
    var newElement = document.createElement("input");
    newElement.setAttribute("name",elementName);
    newElement.setAttribute("type",elementType);
    newElement.setAttribute("value",elementValue);
    inputForm.appendChild(newElement);
    return newElement;
}
function act_pass(obj){
    if(confirm("确定要通过这条记录吗?")){
       //构建form
       var newform=createSubmitForm();
       var updatetime_hid_val=$("#"+obj+"_updatetime_hid").val();
       createNewFormElement(newform,"ComId","hidden",obj);
       createNewFormElement(newform,obj+"_updatetime_hid","hidden",updatetime_hid_val);
       newform.submit();
    }
}
function act_notpass(obj){
    var com_check_box=$("#"+obj);
var com_reason=$("#"+obj+"_reason_tr");
if(com_check_box.attr("checked")){
   com_check_box.attr("checked",false);
   ComIdCheckedSize--;
   $("#checkAll0").attr("checked",false);
   com_reason.css("display","");
   return false;
}else{
      var checkbox = com_reason.find(":checkbox");
  var notChooseLen = checkbox.not(":checked").length;
  if(checkbox.length == notChooseLen){
alert("请选择原因!");
return false;
  }else{
        var judge=false;
  $(":checkbox[name='"+obj+"_reasons'][checked=true]").each(function(){
           if($(this).val()=="4"){
             var otherReasonVal=$("#"+obj+"_otherReason").val();
             if(otherReasonVal==''){
                 judge=true;
             }
           }
    });
    if(judge){
      alert("请输入其他理由!");
      return false;
    }
       if(confirm("确定要不通过这条记录吗?")){
       //构建form
       var newform=createSubmitForm();
       createNewFormElement(newform,"notpassComId","hidden",obj);
       var updatetime_hid=$("#"+obj+"_updatetime_hid");
       var updatetime_hid_val=updatetime_hid.val();   
       createNewFormElement(newform,obj+"_updatetime_hid","hidden",updatetime_hid_val);
       $(":checkbox[name='"+obj+"_reasons'][checked=true]").each(function(){
           //createNewFormElement(newform,obj+"_reasons","checkbox",$(this).val());
           createNewFormElement(newform,obj+"_reasons","hidden",$(this).val());
           if($(this).val()=="4"){
             var otherReasonVal=$("#"+obj+"_otherReason").val();
             createNewFormElement(newform,obj+"_otherReason","hidden",otherReasonVal);
           }
    });
       newform.submit();
    }
  }
}
}

SQLServer的函数:
执行必须带dbo.
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO



ALTER   function f_getAreaNoFrName(@AreaName varchar(32))
RETURNS int AS
BEGIN

    declare @AreaNo int
    if exists (select * from  jobcn90_other.dbo.WorkArea where AreaName like '%'+@AreaName+'%')
    begin
        select top 1 @AreaNo=AreaNo from jobcn90_other.dbo.WorkArea where AreaName like '%'+@AreaName+'%'
    end
    else
    begin
        set @AreaNo=1
    end
758
    return @AreaNo

END


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

不编译的问题



package explorer 包探查器 包资源管理器
hierarchy  等级体系 分层结构 层次结构
source 源  源代码
refactor   重构
navigate   导航 领航 浏览
Pulse is ready to update the selected software.
This profile has been reconfigured, confirm if you would like to update now.
provision

window  窗口
new window 新建窗口
new editor 新建编辑器
open per      打开透视图
             
           显示视图
            
           定制透视图...
           透视图另存为...
           复位透视图
           关闭透视图
           关闭所有透视图
           导航
           工作集
           web brower
           首选项... 
              JAVA:
            Action on double click in the Package Explorer
            当双击包资源管理器时:
            Go into the selecte element
            进入所选元素
            Extend the selected element
            展开所选元素

            When opening a Type Hierarchy
            当打开类型层次结构透视图时
            Open a new Type Hierarchy Perspective
            打开一个新的类型层次透视图
            Show the type Hierarchy View in the current perspective
            在当前透视图显示类型层次视图

            Refactoring Java Code
            重构JAVA代码
            Save all modified resources automatically prior to refactoring
            在重构之前自动保存所有修改过的资源
            Rename in editor without dialog
           
            Search
             Use reduced search menu
             用简化的搜索菜单
             Clear all 'do not show again'settings and show all hidden dialogs again
             清除所有不再显示设置并再次显示所有隐藏的对话框
    
  
prior to
internal
bundle
launch
             
wml1.0
netstat
TreeCache文档 JBossCache-TreeCache体验
分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

Global site tag (gtag.js) - Google Analytics