473,490 Members | 2,635 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

attachEvent does not work in Firefox

7 New Member
Hello friends,
i have written following line of code in javascript for event handler but it works fine with IE but not works with Firefox
it get stuck on "attachevent"

Expand|Select|Wrap|Line Numbers
  1. addScrollSynchronization(divHeaderColumn, divContent, "vertical");
  2.  
  3. function addScrollSynchronization(fromElement, toElement, direction) {
  4. removeScrollSynchronization(fromElement);
  5.  
  6. fromElement._syncScroll = getOnScrollFunction(fromElement);
  7. fromElement._scrollSyncDirection = direction;
  8. fromElement._syncTo = toElement;
  9. toElement.attachEvent("onscroll", fromElement._syncScroll);
  10. }
  11.  
  12. // removes the scroll synchronization for an element
  13. function removeScrollSynchronization(fromElement) {
  14. if (fromElement._syncTo != null)
  15. fromElement._syncTo.detachEvent("onscroll", fromElement._syncScroll);
  16.  
  17. fromElement._syncTo = null;
  18. fromElement._syncScroll = null;
  19. fromElement._scrollSyncDirection = null;
  20. }
  21.  
anybody know any solution plz let me know
Sep 5 '07 #1
6 8803
dmjpro
2,476 Top Contributor
Hello friends,
i have written following line of code in javascript for event handler but it works fine with IE but not works with Firefox
it get stuck on "attachevent"

addScrollSynchronization(divHeaderColumn, divContent, "vertical");

function addScrollSynchronization(fromElement, toElement, direction) {
removeScrollSynchronization(fromElement);

fromElement._syncScroll = getOnScrollFunction(fromElement);
fromElement._scrollSyncDirection = direction;
fromElement._syncTo = toElement;
toElement.attachEvent("onscroll", fromElement._syncScroll);
}

// removes the scroll synchronization for an element
function removeScrollSynchronization(fromElement) {
if (fromElement._syncTo != null)
fromElement._syncTo.detachEvent("onscroll", fromElement._syncScroll);

fromElement._syncTo = null;
fromElement._syncScroll = null;
fromElement._scrollSyncDirection = null;
}


anybody know any solution plz let me know
Please maintain the Code Tags while you do Post.

Look, attachEvent does not work in Firefox.
use addEventListener.
Expand|Select|Wrap|Line Numbers
  1. toElement.addEventListener("scroll", fromElement._syncScroll,true);
  2. fromElement._syncTo.removeEventListener("scroll", fromElement._syncScroll,true);
  3.  
I think it will work.

Kind regards,
Dmjpro.
Sep 5 '07 #2
dotcom
7 New Member
Please maintain the Code Tags while you do Post.

Look, attachEvent does not work in Firefox.
use addEventListener.
Expand|Select|Wrap|Line Numbers
  1. toElement.addEventListener("scroll", fromElement._syncScroll,true);
  2. fromElement._syncTo.removeEventListener("scroll", fromElement._syncScroll,true);
  3.  
I think it will work.

Kind regards,
Dmjpro.

THANKS Dmjpro

but still i am getting error in other line
Expand|Select|Wrap|Line Numbers
  1. divContent.parentElement.style.width = divContent.offsetWidth + headerRowsWidth;
  2.  
it says that divContent.parentElement. has no properties

if u know plz suggest

anyway thanks
Sep 5 '07 #3
dotcom
7 New Member
THANKS Dmjpro

but still i am getting error in other line
divContent.parentElement.style.width = divContent.offsetWidth + headerRowsWidth;

it says that divContent.parentElement. has no properties

if u know plz suggest

anyway thanks

THANKS
Dmjpro

I GOT it now it is not showing error but it is not working
Sep 5 '07 #4
dmjpro
2,476 Top Contributor
THANKS Dmjpro

but still i am getting error in other line
divContent.parentElement.style.width = divContent.offsetWidth + headerRowsWidth;

it says that divContent.parentElement. has no properties

if u know plz suggest

anyway thanks
Hey!
I already told you to use Code Tags.
Expand|Select|Wrap|Line Numbers
  1. divContent.parentNode.style.width = divContent.offsetWidth + headerRowsWidth + "px";
  2. //Do this I think it will work.
  3.  
Best of Luck.

Kind regards,
Dmjpro.
Sep 5 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
dotcom, the lesson here is to test in standards-compliant browsers such as Firefox or Opera first, then test in IE. attachEvent is IE-only and does not work in other browsers. addEventListener is the standard method and is supported by the rest of the modern browsers, but not IE. See this article.

The same applies to parentElement and parentNode. The difference here is that parentNode will work in all browsers.
Sep 5 '07 #6
acoder
16,027 Recognized Expert Moderator MVP
Changed the thread title to better describe the problem. Please use a good thread title. Also use code tags when posting code.
Sep 5 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
14443
by: Bert | last post by:
Hello, I'm having some problems with creating a script that works on both Mozilla browsers as IE. I want to change the background color of textareas and input text fields as soon as somebody...
2
5169
by: jiayanxiang | last post by:
Hi: I used the following code to dynamically add a control and I tried to use attachevent to add a onClick event to the control. It doesn't seem to do anything. Any idea what might be wrong? ...
2
3254
by: zeg37 | last post by:
Hi, I am working with a Microsoft Data Page where the records are filtered by two dates the user selects prior to any records being loaded. After selecting dates they click on a button (BtnGo)...
18
12036
by: luco | last post by:
Hi! I'm having a problem with attachEvent function. I'd like to add attachEvent dynamically to some objects so that each could execute event function with different parameter value. The question...
10
2767
by: Peter Michaux | last post by:
Hi, Today I have been testing the event models from Netscape 4.8 and IE 4 to the current crop of browsers. I'd like to write a small event library similar in purpose to the Yahoo! UI event...
5
12540
by: J | last post by:
I am having problems dynamically adding more than one event handler to an input. I have tried the Javascript included at the bottom. The lines inp.attachEvent('onkeyup',...
1
1961
by: comicgeekspeak | last post by:
Hi there, I am trying to write a loop that will add 10 divs to the screen. Each div will have an onclick event. The function that will be called onclick requires a parameter. That parameter...
6
2296
by: SkyZhao | last post by:
if i use AttachEvent like this,it can't work; eg: var img = document.createElement("img"); img.attachEvent("onclick",alert("test")); var div = document.createElement("div");...
12
3742
by: Max | last post by:
Hi All, I need to check if attachEvent was done to an element. The problem is that attachEvent does not save this information anywhere. Is there any way to do this??? Thanks, Max
0
7112
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6974
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7146
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7183
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.