There are some js syntax on Event handling which i am not familiar, what could be wrong with the codes below? The words are suppose to change when the mouse move in & out...
<head>
<style>
#bannertext {font-family:"Verdana";}
</style>
<script language="javascript">
// Not sure if the below syntax is correct?
function changeColor(element,color){
element.style.color=color;
}
function changeCursor(element,cursor){
element.style.cursor="hand";
}
function changeContent(element,content){
element.style.content=content;
}
function changeSize(element, size){
element.style.size=size;
}
</script>
</head>
<body>
<!-- I know below codes contain multiple mouse events within a single span & erranous but not sure how to write them -->
<SPAN id="bannertext" onmouseout="changeColor(#bannertext,'blue'); changeContent(bannertext, 'Click me...'); changeSize(bannertext, 20);"
onmouseover="changeText(bannertext,'red'); changeContent(#bannertext, 'Do not Click Me');changeSize(bannertext, 30); changeCursor(this)";
onclick="clickText(bannertext,'green'); changeContent(#bannertext, 'Some text');changeSize(bannertext, 50)";>
Click here to proceed...
</SPAN>
6 1982 iam_clint 1,208
Recognized Expert Top Contributor
fixed you up a bit good luck -
<head>
-
<style>
-
#bannertext {font-family:"Verdana";}
-
</style>
-
<script language="javascript">
-
// Not sure if the below syntax is correct?
-
function changeColor(element,color){
-
element.style.color=color;
-
}
-
function changeCursor(element,cursor){
-
element.style.cursor="hand";
-
}
-
function changeContent(element,content){
-
element.style.content=content;
-
}
-
function changeSize(element, size){
-
element.style.size=size;
-
}
-
</script>
-
</head>
-
<body>
-
<!-- I know below codes contain multiple mouse events within a single span & erranous but not sure how to write them -->
-
<SPAN id="bannertext" onmouseout="changeColor(this,'blue'); changeContent(bannertext, 'Click me...'); changeSize(this, 20);"
-
onmouseover="changeColor(this,'red'); changeContent(this, 'Do not Click Me'); changeSize(this, 30); changeCursor(this)";
-
onclick="changeColor(bannertext,'green'); changeContent(this, 'Some text');changeSize(this, 50)";>
-
Click here to proceed...
-
</SPAN>
-
Thanks, however the text still remain the same. What is the reason?
acoder 16,027
Recognized Expert Moderator MVP
Thanks, however the text still remain the same. What is the reason?
There's a few mistakes. You can't use content to change content. Use innerHTMl (non-standard) or something similar to change the content. If using innerHTML, use without style directly on the span.
'hand' is not valid, you have to use 'pointer' instead. Your function is not called correctly too.
Instead of size, use fontSize.
That should solve your problems.
Actually I have tried both 'pointer' and 'hand', both actually worked! I also tried the playing around with size, fontsize, font-size... doesn't seem to work. There has got to be an easier method than to assign an id & use innerHTML, right?
acoder 16,027
Recognized Expert Moderator MVP
Actually I have tried both 'pointer' and 'hand', both actually worked! I also tried the playing around with size, fontsize, font-size... doesn't seem to work. There has got to be an easier method than to assign an id & use innerHTML, right?
You need to use foneSize (notice the case of S), not fontsize. You don''t need to use an id. Just use - element.innerHTML = content;
There might be another way too, but this is easy.
If you need more help, let me know.
Acoder, thanks... I got it... now it worked. You are correct in saying that it should be fontSize rather than fontsize. Also, simply replacing the function inside with the following resolve the problem:
function changeContent(element,content){
bannertext.innerHTML = content;
}
I find it strange that while other attribute can change its own attribute, but it does not work in the case of the content attribute(i.e. content cannot change content as you mentioned earlier). I am still puzzle as to the reason...
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Noor |
last post by:
please tell the technique of centralize exception handling without try catch
blocks in c#.
|
by: Eric Newton |
last post by:
VB's more declarative nature of handling events is golden. I'm hoping C#
will acquire this type of deal, in addition to the anonymous delegates.
could do same as vb (actually would be easier to...
|
by: hillcountry74 |
last post by:
Hi,
I'm a newbie and trying to understand event handling in c#. I have
understood handling events using delelgate objects. But not this
method- "Event handling by overriding the virtual...
|
by: Ashok Kumar K |
last post by:
Hi all,
Where can I get some insight on using the __hook, __unhook, event_source and
event_receiver for specifically COM events. The documentation given in MSDN
is very minimal. I have the...
|
by: Sridhar |
last post by:
Hi,
I have created a web page which includes a place holder. I also have a
dropdown list in that webpage. when I select one of the choices in that
dropdown list, It will load a user control...
| |
by: Paul E. Orman |
last post by:
I have a piece of VB code (.NET 1.1 - VB 2003) that loads data from a
database through a timer. So the timer is setup and from it I call the
procedure that loads the latest records from the...
|
by: chopsnsauce |
last post by:
Here's the example:
Dim frm As New FORM1
Try
frm.show
Catch ex As Exception
msgbox ex.message
|
by: reggiestyles |
last post by:
Hi,
I've got a question about prototype and event handling.
I've got several div's (dynamic number) on a page that I want to set as
active or inactive (basically, I'm using scriptaculous'...
|
by: Mythran |
last post by:
I once read an article somewhere describing why we should not override the
OnXXX methods of classes when you want to extend the functionality of a
class. It stated that you should handle the event...
|
by: stmfc |
last post by:
hi,
for an event handling mechanism,
we need an event object. (the object where the event actually occur)
and we need an event handler,
and we need a registration of the event handler to the...
|
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,...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |