[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [flashproxy/master] Add wrapper function to attach DOM events.
commit e2d353475109bfa587a685c006818980572974cb
Author: Alexandre Allaire <alexandre.allaire@xxxxxxxxxxxxxx>
Date: Thu Dec 6 19:03:59 2012 -0500
Add wrapper function to attach DOM events.
The current code uses the standard addEventListener
which is not supported in IE <= 8. Add a small
wrapper function which uses the IE attachEvent method
if it is available.
---
proxy/options.js | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/proxy/options.js b/proxy/options.js
index 326043e..f39f358 100644
--- a/proxy/options.js
+++ b/proxy/options.js
@@ -6,7 +6,16 @@ var COOKIE_NAME = "flashproxy";
/* max-age is not supported in IE. */
var COOKIE_LIFETIME = "Thu, 01 Jan 2020 00:00:00 GMT";
-window.addEventListener("load", function () {
+/* This wrapper will attach events correctly in older
+ versions of IE. */
+function add_event(elem, evt, handler) {
+ if (elem.attachEvent)
+ elem.attachEvent("on" + evt, handler);
+ else
+ elem.addEventListener(evt, handler);
+}
+
+add_event(window, "load", function () {
function cookie_present() {
var cookies = document.cookie.split(";");
@@ -46,9 +55,9 @@ window.addEventListener("load", function () {
if (navigator.cookieEnabled) {
var buttons = document.getElementById("buttons");
- buttons.addEventListener("click", update_setting_text);
- document.getElementById("yes").addEventListener("click", set_cookie);
- document.getElementById("no").addEventListener("click", del_cookie);
+ add_event(buttons, "click", update_setting_text);
+ add_event(document.getElementById("yes"), "click", set_cookie);
+ add_event(document.getElementById("no"), "click", del_cookie);
buttons.style.display = "block";
update_setting_text();
} else {
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits