473,943 Members | 14,067 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

attach event problem

where is the problem in below code, i am not getting o/p

img=document.cr eateElement('IM G');
img.src='Images \\add.gif';
img.style.curso r='hand';
//evnt=document.c reateAttribute( "onmouseove r");
//evnt.nodeValue= "test();";
//img.addEventLis tener("onmouseo ver","test();", false);
img.attachEvent ("onmouseover", "test();");
td.appendChild( img);
document.body.a ppendChild(tbl) ;

Nov 23 '05 #1
1 5130
su************* **@gmail.com wrote:
where is the problem in below code, i am not getting o/p
What is 'o/p'? What is the actual problem you have?

There are many possible problems with your code, the snippet you have
posted is too brief to know what the error might be:

img=document.cr eateElement('IM G');
Is this part of a function? If so, img should be kept local with 'var':

var img = document.create Element('IMG');

img.src='Images \\add.gif';
Two slashes in the image path? that indicates an directory with no
name, what OS allows that? Paths on the web use forward slashes:

img.src='Images/add.gif';

img.style.curso r='hand';
'hand' is not a valid CSS 2 value for the cursor property, 'pointer' is:

img.style.curso r='hand';

<URL:http://www.w3.org/TR/CSS2/ui.html#propdef-cursor>

//evnt=document.c reateAttribute( "onmouseove r");
//evnt.nodeValue= "test();";
//img.addEventLis tener("onmouseo ver","test();", false);
img.attachEvent ("onmouseover", "test();");
It's much simpler to add events using:

img.onmouseover = test;

td.appendChild( img);
I guess 'td' is a reference to an element (probably a table cell) that
was declared/initialised elsewhere.

document.body.a ppendChild(tbl) ;


At some point was 'td' added to the document? If it's a table cell, it
must be added to a table row. There are a number of quirks regarding
adding a row to a table, might the issue be there?

Have you done appropriate feature testing for the DOM interfaces and
methods you are using elsewhere?
--
Rob
Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4096
by: Aymer | last post by:
i created a new button object. how do i attach an event on it? thanx for your help. Dim cc As ColorConverter = new ColorConverter() Dim b = new button() b.ID = "SelectedDate" b.BorderStyle = 1 b.forecolor = cc.ConvertFromString("red") b.BackColor = cc.ConvertFromString("white")
1
3904
by: Robert Oschler | last post by:
I've successfully attached to the "onclick" and several other events using AttachEvent(). But when I try to attach to the "onbeforeunload" event it doesn't work (the handler I've assigned is never called). Is there something different about this event? Is there another way to attach to this event that would work, other than manually filling in the <BODY> tag with an 'onunloadbefore' assignment? thx
4
2901
by: bhatiaajay | last post by:
I am new to JavaScript objects. The object creates a button with no events attached. Later I want to attach an event to the button created by this object. The event attaches a function in the object. The code is listed below but the event is never attached. The 'this' reference for the button seem to be correct and the 'self' reference to the control(object) also seems to be correct.
4
2074
by: Julie J. | last post by:
When working w/ forms and controls, in 95% of the cases, the value of the control is used somewhere in the program (duh!). However, there doesn't seem to be an easy way to attach a value variable to that control the automatically handles synchronization of the value w/ the contol. Here is an example: // some form
2
2133
by: Zieben | last post by:
Hello! I have such problem! I have my UserControl. I override property ContextMenu for this Control as ..... new ContextMenu ContextMenu{ set {_contextMenu = value;}
2
1820
by: Ashish | last post by:
Hello, I am sick and tired of ochestrating server and client side scripts. Basically I am using toolbar from IE web controls and want to attach javascript to one of the buttons' click event. The problem is that button doesnt exposes attribute collection. I can attach javascript to whole toolbar but 1. it would defeat the purpose of only attaching client scripts to some buttons 2. i would have no means of identifying which button was...
1
1873
by: Nirmalkumar | last post by:
How to attach an event to dynamically created control in VB.NET I have dynamically created dropdown list in code behind (VB.NET). For this control I want to attach an event for action ‘OnSelectedIndexChanged’. What is the property to assigne an event to a dynamically created dropdownlist
2
1330
by: harel.moshe | last post by:
Hey everybody, I'm looking for a way to attach non-void events to a server control i wrote. Relevant code parts: the control: mycontrol : WebControl {
13
2487
by: pamelafluente | last post by:
Hello. I have written the following code (this code is on a control): Sub InitSomething() mSet(me.FindForm) End Sub Sub mSet(ByVal f As Control) For Each t As Control In f.Controls If TypeOf t Is ToolStripMenuItem Then AddHandler t.MouseEnter, AddressOf Me.SetSemaforoMenu
1
1864
by: sindhu | last post by:
Hello, I am able to attach event to dynamically created element.as shown below. for(var i=0;i<10;i++) {for(var j=0;j<15;j++) { var div=document.createElement('div'); div.setAttribute("name","div"+i+j); div.setAttribute("id","div"+i+j);
0
11131
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11300
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10665
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8222
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6089
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6310
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4912
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 we have to send another system
2
4512
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3513
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.