* Adds event handler to the target object. * @param {Object} obj Target object. * @param {String} type Name of the event. * @param {Function} func Handling function.
(obj, type, func, scope)
| 613 | * @param {Function} func Handling function. |
| 614 | */ |
| 615 | function attachEvent(obj, type, func, scope) |
| 616 | { |
| 617 | function handler(e) |
| 618 | { |
| 619 | e = e || window.event; |
| 620 | |
| 621 | if (!e.target) |
| 622 | { |
| 623 | e.target = e.srcElement; |
| 624 | e.preventDefault = function() |
| 625 | { |
| 626 | this.returnValue = false; |
| 627 | }; |
| 628 | } |
| 629 | |
| 630 | func.call(scope || window, e); |
| 631 | }; |
| 632 | |
| 633 | if (obj.attachEvent) |
| 634 | { |
| 635 | obj.attachEvent('on' + type, handler); |
| 636 | } |
| 637 | else |
| 638 | { |
| 639 | obj.addEventListener(type, handler, false); |
| 640 | } |
| 641 | }; |
| 642 | |
| 643 | /** |
| 644 | * Displays an alert. |
no outgoing calls
no test coverage detected