Questions tagged [attachevent]
44 questions
85
votes
2 answers
Correct usage of addEventListener() / attachEvent()?
I'm wondering how to use addEventListener respectively attachEvent correctly?
window.onload = function (myFunc1) { /* do something */ }
function myFunc2() { /* do something */ }
if (window.addEventListener) {
window.addEventListener('load',…

ginny
- 859
- 1
- 7
- 5
6
votes
2 answers
Safe, universal, way to use addEventHandler in Javascript?
Before I get into the details of this problem, I'd like to make the situation clear. Our web analytics company works as a consultant for large sites, and (other than adding a single SCRIPT tag) we have no control over the pages themselves.
Our…

blakeyrat
- 101
- 1
- 4
4
votes
4 answers
Scope troubles in Javascript when passing an anonymous function to a named function with a local variable
Sorry about the title - I couldn't figure out a way to phrase it.
Here's the scenario:
I have a function that builds a element:
buildSelect(id,cbFunc,...)
Inside buildSelect it does this:
select.attachEvent('onchange',cbFunc);
I also have an…

encee
- 4,544
- 4
- 33
- 35
3
votes
1 answer
Cross-browser event handling
I need a cross-browser function for registering event handlers and a (mostly) consistent handler experience. I don't need the full weight or functionality of a library such as jQuery, so I've written my own. I believe I've accomplished my goals with…

Billy Jo
- 1,326
- 19
- 32
2
votes
1 answer
element.dispatchEvent is not a function
I wrote a plugin , but whene Active ,disable Editor and in firebug Mozila below error Is shown
element.dispatchEvent is not a function prototype.js:5457
and line 5457 prototype.js
if (document.createEvent)
5457: …

Mostafa
- 39
- 1
- 2
- 5
2
votes
1 answer
AttachEvent Not Working on IE11
I am trying to make two checkboxes, out of which only one can be selected at any point of time. I searched the forums a lot and found a few suggestions.
if (document.attachEvent){
// For IE Browsers.
document.attachEvent("DOMContentLoaded",…

hell_storm2004
- 1,401
- 2
- 33
- 66
2
votes
0 answers
Javascript: Event listeners for windows media player in IE11
I have come across an issue in the code base I working with in IE11 specifically.
Other versions of IE allow me to listen to a specific event called 'OpenStateChanged' which is fired from Windows Media Player like…

Thewads
- 4,953
- 11
- 55
- 71
1
vote
2 answers
Attaching JQuery Events to "on the fly created" controls
I'm appending to an existing div in my page. The appended text contains html code in string. The problem is, events aren't working when I add click on them after appending to page. I guess Jquery loads control on page load and I have to do something…

Pabuc
- 5,528
- 7
- 37
- 52
1
vote
1 answer
javascript attachEvent within loop
I'm using the code below within a loop. It works so long as I'm not using IE.
var remove = document.createElement("input");
remove.type = "button";
remove.value = "x";
if (remove.addEventListener) {
remove.addEventListener("click",…

rollsRLS8822
- 47
- 2
- 7
1
vote
2 answers
Javascript converting addEventListener to attachEvent
I have the following code calling a Javascript function in a nice shiny standards complient manner :). Please note that I must send elementsList[i] to the function (the this keyword will not be adaquate) as the event listerner is being attached to…

YsoL8
- 2,186
- 5
- 29
- 47
1
vote
1 answer
IE7: call is undefined on document.attachEvent function
I was trying to call .call Function prototype method on document.attachEvent in IE7. But it is showing as undefined.
I have also checked typeof document.attachEvent, is should show as function but it is object.
Can someone explain it…

hemkaran_raghav
- 1,346
- 11
- 25
1
vote
3 answers
How to attach event with object for resize & click
I am using jQuery version 1.4.1. I try to attach resize & click events this way but it is not working.
var $els = [];
$els.window = $(window);
$els.window.bind('resize', getNewWindowCorner());
$els.toggleUPSButtons.bind('click',…

Thomas
- 33,544
- 126
- 357
- 626
1
vote
1 answer
Addeventlistener fallback for older IE
I am trying to create a simple fallback function, which will make sure addeventlistener will work in IE versions older than 9.
So far i have this
if (!Element.prototype.addEventListener)
{
Element.prototype.addEventListener =
…

user3240613
- 37
- 3
1
vote
2 answers
JavaScript event handler
I am trying to fix a bug with the mouseenter and mouseleave handler.
listener.addEventListener('mouseenter', function(){
element.style.visibility = "visible";
}, true);
listener.addEventListener('mouseleave', function(){
…

user3330630
- 17
- 4
1
vote
0 answers
attachEvent and addEvent render unexpected result
I guess I must have made some amateur mistake that I keep on overlooking, but I can't seem to figure it out.
I'm making a onepage smoothscrolling website. If you scroll, the browser detects the direction and then scrolls you to the appropriate div.…

Mats Raemen
- 1,781
- 1
- 28
- 41