473,800 Members | 2,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding Events to newly created controls question...

I'm having a hard time getting this code to work...the onMouseOver and
onMouseOut events don't seem to be firing in IE or Mozilla.....tha nks
in advance for any assistance...

var imgf = document.create Element("img");
imgf.src = "../files/img.gif";
imgf.style.curs or = "pointer";
imgf.style.bord er = "1px solid blue";
imgf.title = "Date selector";

// below is not working at all......

imgf.onMouseOve r = "this.style.bac kground='blue'; ";
imgf.onMouseOve r = "this.style.bac kground='';";
Thanks again!

Michael

Nov 6 '05 #1
10 1176
xx********@supe rgambler.com wrote:
I'm having a hard time getting this code to work...the onMouseOver and
onMouseOut events don't seem to be firing in IE or Mozilla.....tha nks
in advance for any assistance...

var imgf = document.create Element("img");
imgf.src = "../files/img.gif";
imgf.style.curs or = "pointer";
imgf.style.bord er = "1px solid blue";
imgf.title = "Date selector";

// below is not working at all......

imgf.onMouseOve r = "this.style.bac kground='blue'; ";
imgf.onMouseOve r = "this.style.bac kground='';";

imgf.onmouseove r = function(){this .style.backgrou ndColor='blue'; }

Mick
Nov 6 '05 #2
Thanks you very much.....looked all over the place for this....is there
a good DOM reference book you know of?? or where info like this is
located?

Thanks again!

Nov 6 '05 #3
Mick White wrote:

imgf.onmouseove r = function(){this .style.backgrou ndColor='blue'; }

Oops, makes no sense to assign a background colour to an image

imgf.onmouseove r = function(){this .parentNode.sty le.backgroundCo lor='blue';}

Mick
Nov 6 '05 #4
xx********@supe rgambler.com wrote:
Thanks you very much.....looked all over the place for this....is there
a good DOM reference book you know of?? or where info like this is
located?

Thanks again!

http://www.mozilla.org/docs/dom/domref/dom_shortIX.html

Mick
Nov 6 '05 #5
Mick White wrote:
Mick White wrote:

imgf.onmouseove r = function(){this .style.backgrou ndColor='blue'; }

Oops, makes no sense to assign a background colour to an image

imgf.onmouseove r =
function(){this .parentNode.sty le.backgroundCo lor='blue';}

Caveat: The image needs to be appended to its parent before you may
reference the parentNode.
Mick
Nov 6 '05 #6
Thanks Mick.....you seem very knowledgable on these things, mind if I
ask you another question.....

I'm trying to set the class of a newly created object

I've tried the following two statements...

imgf.class = "classname" ;
imgf.style.clas s = "classname" ;

This doesn't seem to work, it causes a JavaScript error message......do
you know the correct syntax?

Thanks

Michael

Nov 8 '05 #7

xx********@supe rgambler.com wrote:
Thanks Mick.....you seem very knowledgable on these things, mind if I
ask you another question.....

I'm trying to set the class of a newly created object

I've tried the following two statements...

imgf.class = "classname" ;
imgf.style.clas s = "classname" ;
Correct syntax is as follows:

imgf.className = "classname" ;

This doesn't seem to work, it causes a JavaScript error message......do
you know the correct syntax?

Thanks

Michael


Nov 8 '05 #8
xx********@supe rgambler.com wrote:
I'm trying to set the class of a newly created object

I've tried the following two statements...

imgf.class = "classname" ;
imgf.style.clas s = "classname" ;

This doesn't seem to work, it causes a JavaScript error message......
"a JavaScript error message" is as bad an error description as any.
do you know the correct syntax?


<FAQENTRY>

Since `class' is a reserved word in several interfacing languages,
including JS/ECMAScript, it cannot be used for identifiers which is
why the DOM Level 2 HTML ECMAScript binding specifies the `class'
attribute of HTML elements to be accessible through the implemented
`className' attribute of HTMLElement objects.

imgf.className = "classname" ;

See <http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-213157251>.

</FAQENTRY>

BTW, that is a FAQ here; not covered by the FAQ list[1] yet, however it can
be searched through (Google Groups) archives which is the first thing one
should do before posting.

<http://jibbering.com/faq/#FAQ2_11>
PointedEars
___________
[1] <http://jibbering.com/faq/>
Nov 8 '05 #9
thanks!

Nov 8 '05 #10

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

Similar topics

6
2836
by: Amir Hardon | last post by:
I'm new to DOM and can't figure out this thing: I'm trying to add a row to a table with a form field in one of it's cells, but if I'm appending the field to a form it gets out of the table. Can some one tell me what I'm doing wrong? it looks like this: var tbl=document.tbl; var frm=document.frm; var newcell=document.createElement("TD");
3
4888
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that the best method? Do you have a sample of how to do this?
2
2233
by: JezB | last post by:
I'm adding WebControl objects to a Page dynamically on Page_Load, but I'm having trouble attaching events to these. For example, adding an image button :- ImageButton nb = new ImageButton(); nb.ImageUrl = "text.gif"; nb.ToolTip = "Edit Text"; nb.Click += new ImageClickEventHandler(b1_Click); myPlaceholder.Controls.Add(nb);
0
1099
by: Steve Moreno | last post by:
Hi all, I've got a web form that I've written code to create an array of DropDownList controls on the page depending on how many records are pulled back. The code to create the controls is working fine but now I need to add events to the newly created DropDownList controls. I need to add the SelectedIndexChanged event and I'm having a hard time getting the code to add events to the controls since the names (IDs) are varied to include...
5
2724
by: Steve Moreno | last post by:
Hi all, I've got a web form that I've written code to create an array of DropDownList controls on the page depending on how many records are pulled back. The code to create the controls is working fine but now I need to add events to the newly created DropDownList controls. I need to add the SelectedIndexChanged event and I'm having a hard time getting the code to add events to the controls since the names (IDs) are varied to include...
9
2781
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT IS IMPOSSIBLE TO PROGRAMMATICALLY ADD A BUTTON TO A DYNAMICALLY CREATED PAGE. Or, to be more precise, why it is impossible to have an onClick sub respond to that button’s Click event. My main page has only one line:
2
1498
by: Oleg Ogurok | last post by:
Hi all, Does anyone have example of adding controls on the client side (DHTML) and then persisting them as ASP.NET server controls on the server side? For example, a page has an <input> box for entering e-mail address and a button <Add more addresses>.
6
1597
by: Totto | last post by:
Hi, Anyone know the best solution to dynamically add buttons to a asp 2.0 page using data from Sql server? Are there any contols suitable for this or is it best to iterate the dataset and dynamicaly add buttons in the asp page? Totto
5
6765
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created link buttons to stay wired up to their click events. I have what is basically a simply survey question generation page. The page first displays a few static fields and a dropdownlist of various options for the user to select. When the user...
0
9691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10276
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
10253
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
10035
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...
0
9090
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7580
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
5471
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
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
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.