473,408 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Custom Object property not working

I'm trying to create a custom js object to display help text when you
move the mouse over controls on a form. I've got two issues that are
troubling:

1) The 'color' and 'backgroundColor' properties only have values
immediately after you set them. Trying to access them from within the
object later with this.color yields "undefined"

2) Having trouble with the syntax for addEventListener. Can't get
that to work in IE6 so I'm currently overwriting any preexisting
'onmouseover' events.

Any ideas on how to get either of these to work?

Thanks,
Jesse
<html>
<head>
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<TITLE></TITLE>
<STYLE>
BODY{ margin:.5em; font-family:sans-serif}
DIV{ margin:0px; padding:.5em; height:3em; width:50%;
float:left; }
H6{ margin:0px; }
INPUT{ width:100% }
</STYLE>
<script>

function HelpText(color, bgColor){
var _lastEl;

this.color=color;
this.backgroundColor=bgColor;

this.doMouseOver=
function(){
//Exit if the pointer is over the same control
el=window.event.srcElement;
if(el == _lastEl) return false;
_lastEl=el;

//Get the div above this control
while(el.tagName != "DIV" && el.tagName != "BODY"){
el=el.parentNode;
}

if(el.help && el.help.length != 0){
dvHelp.innerHTML=el.help;
dvHelp.style.display="inline";
dvHelp.style.color=this.color;
dvHelp.style.backgroundColor=this.backgroundColor;
window.status = this.backgroundColor;
}

}

this.doMouseOut=
function(){
dvHelp.innerHTML="";
dvHelp.style.display="none";
}
dvHelp=document.createElement("DIV")
dvHelp.style.display="none";
window.document.body.appendChild(dvHelp);

window.document.body.onmouseover=this.doMouseOver;
window.document.body.onmouseout=this.doMouseOut;
//window.document.addEventListener("onmouseout",
this.doMouseOut, false);
}
</script>
</head>
<BODY onload="var oHelp=new HelpText('black','yellow');">
<DIV help="First name of customer as it appears on credit card">
<H6>First Name</H6>
<INPUT type="text" ID="Text1" NAME="Text1">
</DIV>
<DIV help="Last name of customer as it appears on credit card">
<H6>Last Name</H6>
<INPUT type="text" ID="Text2" NAME="Text2">
</DIV>
<DIV help="Preferred shackle chain color">
<H6>Chain Color</H6>
<INPUT type="text" ID="Text3" NAME="Text3">
</DIV>
<DIV help="Name of customer's fantasy alter ego">
<H6>Alter Ego</H6>
<INPUT type="text" ID="Text4" NAME="Text4">
</DIV>
</BODY>
</html>
Jul 20 '05 #1
4 3676

"Jesse Wade" <jw***@rubytuesday.com> schrieb im Newsbeitrag news:9d**************************@posting.google.c om...
I'm trying to create a custom js object to display help text when you
move the mouse over controls on a form. I've got two issues that are
troubling:

1) The 'color' and 'backgroundColor' properties only have values
immediately after you set them. Trying to access them from within the
object later with this.color yields "undefined"

2) Having trouble with the syntax for addEventListener. Can't get
that to work in IE6 so I'm currently overwriting any preexisting
'onmouseover' events.

Any ideas on how to get either of these to work?


For browser-independent event listeners, you could use my ISKEET
library v0.0.4 or later.

http://www.iskeet.de

It also simplifies the handling of page elements.

To find an element on the page, define a tag with an ID field,
which you've already done, as in:

<input id="text1" name="text1" type="text">

Then, you can use ISKEET_DEO.findElementById() in the script
to retrieve the element:

var text1elem = ISKEET_DEO.findElementById( "text1" );
if ( text1elem != undefined ) {
...
}

To set an event handler for it, simply do

ISKEET_DEO.addEventHandler( "mouseover", text1elem, doMouseOver );
ISKEET_DEO.addEventHandler( "mouseout", text1elem, doMouseOut );

So, you can do something like:

var text1elem = ISKEET_DEO.findElementById( "text1" );
if ( text1elem != undefined ) {
ISKEET_DEO.addEventHandler( "mouseover", text1elem, doMouseOver );
ISKEET_DEO.addEventHandler( "mouseout", text1elem, doMouseOut );
}

To add a load handler for a window, write:

ISKEET_DEO.addEventHandler( "load", window, doLoad );

I hope this helps! :-)
Jul 20 '05 #2

"Ekkehard Morgenstern" <ek******************@onlinehome.de> wrote:
var text1elem = ISKEET_DEO.findElementById( "text1" );


duh, this should read:

var text1elem = ISKEET_DEO.getElementById( "text1" );
Jul 20 '05 #3
While I appreciate the reply, your response doesn't help me learn why my
custom object doesn't work, does it? I figured half of it out on my
own. The property references don't work because "this" in the context
of the event handler doesn't refer to the custom object.
Best Regards,

Jesse Wade
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4

"Jesse Wade" <jw***@rubytuesday.com> wrote:
While I appreciate the reply, your response doesn't help me learn why my
custom object doesn't work, does it? I figured half of it out on my
own. The property references don't work because "this" in the context
of the event handler doesn't refer to the custom object.


this, and addEventListener() is only supported by DOM 2.0 events,
which are not supported by IE 6, hence that wouldn't work. ;-)
Jul 20 '05 #5

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

Similar topics

3
by: Steve | last post by:
Guys, I've written a custom control (or at least tweaked someone else's!) in C# to be used on forms (rather than asp.net forms). The control is a date time picker, but its Value property returns...
4
by: Rudy | last post by:
Hello all, I'm sure there is, just can't figure it out. I have the RGB code and the color number. But the color doesn't exsist in Visual studio.net. Can I add this color to the system pallet it...
5
by: Steven Baggs | last post by:
Hi!, I have defined a List<T> like this List<Container> Container class holds my Item object and it's state as a Enum. Container.Item Container.State I would like to bind it to GridView.
6
by: Steve Amey | last post by:
Hi all I want to be able to throw a custom error up the call stack. I have looked around and it seems as though it's possible, but I can't get it to work :o( Below is some sample code. ...
2
by: AMDRIT | last post by:
Hello everyone, I have created a custom component and one of its properties is a class object with it's own properties. During runtime, I can assign values to the class object properties just...
9
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate>...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
0
by: ChopStickr | last post by:
I have a custom control that is embedded (using the object tag) in an html document. The control takes a path to a local client ini file. Reads the file. Executes the program specified in...
4
by: Linda Liu[MSFT] | last post by:
Hi Moondaddy, I downloaded your sample project and run it and did see the problem on my side. There're three problems in the source code of your project. 1. You should move the following...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...
0
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...

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.