首页 > 代码库 > javascript方法

javascript方法

?
1
2
3
4
5
6
7
8
9
10
function fireEvent(element, event) {
                if (document.createEventObject) {
                    var evt = document.createEventObject();
                    return element.fireEvent(‘on‘ + event, evt)
                } else {
                    var evt = document.createEvent("HTMLEvents");
                    evt.initEvent(event, true, true)
                    return !element.dispatchEvent(evt);
                }
  }

  

?
1
2
3
function filterHTML(source) {
 return !source ? "" : source.replace(/<\/?[^>]*>/g, "").replace(/[ | ]*\n/g, "\n"). replace(/\n[\s| | ]*\r/g, "\n").replace(/ /ig, "")
 }