zoukankan      html  css  js  c++  java
  • IE兼容问题

    1、IE下event事件没有target属性,只有srcElement属性,解决方法:使用srcObj = event.srcElement ? event.srcElement : event.target;

     srcObject =event.target||event.srcElement.

    JavaScript的特性:2||3=2

    2、Document.creareEvent()

    Creates an event of the type specified. The returned object should be first initialized and can then be passed to element.dispatchEvent.

    event.initEvent(type, bubbles, cancelable);

    type:is a DOMString defining the type of event

    bubbles:is a Boolean deciding whether the event should bubble up through the event chain or not. Once set, the read-only property Event.bubbles will give its value.

    cancelable:is a Boolean defining whether the event can be canceled.Once set, the read-only property Event.cancelable will give its value.

    example:

    // Create the event.
    var event = document.createEvent('Event');
    
    // Define that the event name is 'build'.
    event.initEvent('build', true, true);
    
    // Listen for the event.
    elem.addEventListener('build', function (e) {
      // e.target matches elem
    }, false);
    
    // target can be any Element or other EventTarget.
    elem.dispatchEvent(event);

    3、fireEvent method

    Fires a special evnet on the object

  • 相关阅读:
    使用fiddler2抓取手机发出的请求信息
    HTML转义字符集合
    spm3安装和使用
    JSP
    Servlet
    Struts2
    java多线程-消费者和生产者模式
    java异常处理机制(try-catch-finally)
    java内部类
    java上转型和下转型(对象的多态性)
  • 原文地址:https://www.cnblogs.com/yulian/p/6148525.html
Copyright © 2011-2022 走看看