I want to make a program that, when you have the mouse on a word, that word
is bold... and when you don't have the mouse on that word, the word is not
bold. Excuse me for my poor English :-(
But the program doesn't work properly. Does somebody know why? This is the
program:
<html>
<head>
<script language="javas cript">
function enter (where) {
// Function for put a text in bold style
document.all("d ebugTable").inn erText += "enter ";
where.innerHTML ="<b>"+where.in nerText+"</b>";
}
function leave (where) {
// Function for put a text in not-bold style
document.all("d ebugTable").inn erText += "leave ";
where.innerHTML =where.innerTex t;
}
</script>
</head>
<body>
<p><center>
<font face="arial" onmouseover="ja vascript:enter( this)"
onmouseout="jav ascript:leave(t his)">Example text</font>
<p>DEBUG:<br><t able><tr><td id="debugTable" ></td></tr></table>
</center>
</body></head>
--
CARLOS GRIMA
· Personal Web: www.carlosgrima.com
· Email & MSN: ca*********@car losgrima.com 9 1463
On Sun, 14 Nov 2004 12:39:18 GMT, Carlis <li****@carlosg rima.com> wrote: I want to make a program that, when you have the mouse on a word, that word is bold... and when you don't have the mouse on that word, the word is not bold.
You can do this, but it may not be a good idea. Effects that result in
size change can, in extreme cases, cause a page to reflow. Not only does
this look unprofessional, but it can frustrate users when something
they're trying to target moves.
Please think carefully about this.
Excuse me for my poor English :-(
Your English is fine. :)
If you feel more comfortable using your native language, do so, but it's a
good idea to provide an English translation if you're able.
But the program doesn't work properly.
In which browsers?
Does somebody know why?
There are several things wrong with the code you presented, not limited to
the script.
This is the program:
<html>
HTML documents should always contain a document type declaration
(DOCTYPE). See <URL:http://www.w3.org/TR/html4/struct/global.html#h-7.2>
for more information.
<head>
HTML documents also require a TITLE element.
<script language="javas cript">
The language attribute has been deprecated for over six years. Use the
required type attribute in its place:
<script type="text/javascript">
function enter (where) { // Function for put a text in bold style document.all("d ebugTable").inn erText += "enter ";
Both document.all and the innerText property are proprietary elements
invented by Microsoft. Their support amongst other user agents is limited
so they should be avoided.
where.innerHTML ="<b>"+where.in nerText+"</b>";
The B element is deprecated, as are other presentational elements and
attributes. Use CSS (see <URL:http://www.w3.org/Style/CSS/>) instead.
[snip]
<p><center>
This is invalid mark-up. P elements may only contain text and inline
elements. CENTER, which is deprecated, is a block-level element.
<font face="arial"
The FONT element is deprecated.
onmouseover="ja vascript:enter( this)" onmouseout="jav ascript:leave(t his)">
The javascript: prefix is meaningless in the majority of user agents, and
is usually superfluous in IE.
Example text</font>
<p>DEBUG:<br><t able><tr><td id="debugTable" ></td></tr></table>
Again, this is invalid. The TABLE element is block-level. Moreover, a
table is inappropriate: tables mark-up tabular data and are not meant for
layout.
</center> </body></head>
I think you'll agree that the mark-up should end, </html>, not </head>.
I strongly suggest you validate (see <URL:http://validator.w3.or g/>) your
mark-up. Trying to script an invalid document can lead to unpredictable
behaviour.
What you are trying to achieve is really quite simple:
function setWeight(o, v) {
if(o && (o = o.style)) {o.fontWeight = v;}
}
<span onmouseover="se tWeight(this, 'bold')"
onmouseout="set Weight(this, '')">Example Text</span>
A full markup example can be found at
<URL:http://www.mlwinter.pw p.blueyonder.co .uk/clj/carlis/bold.html>. Be
aware that it will be deleted in due course.
Hope that helps,
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Very thanks Michel for your detailed response.
Im very surprised about the amount of things that have changed in plane HTML
and JavaScript... For example: the label <b> deprecated!!!! :-S
I have already tested your script and it works perfectly, but i don't
understand it a lot :-( I see i have to start studying HTML and JavaScript
from the beginning again, because most things that you said me are new for
me.
The documentation of HTML, JavaScript and DHTML that i have is from 1998 (i
don't attach it because it is 3 megas, but i can send to you if you want).
Anyway, may be if i use your suggestions the web could not work in old
versions of Explorer or Netscape.
What is your opinion about everything?
Very thanks Michael. Im Spanish and Im 26, and you? :-)
--
CARLOS GRIMA
· Personal Web: www.carlosgrima.com
· Email & MSN: ca*********@car losgrima.com
"Carlis" <li****@carlosg rima.com> wrote in message
news:If******** *************** @telenews.telel ine.es... Very thanks Michel for your detailed response.
Im very surprised about the amount of things that have changed in plane
HTML and JavaScript... For example: the label <b> deprecated!!!! :-S
<B> is depreciated? According to my copy of the HTML 4.01 Specifications it
isn't. <FONT> and <BASEFONT> are depreciated, as are <STRIKE>, <S> and <U>,
but <B> is definitely not indicated as depreciated.
Is there a newer HTML Specification I am not aware of?
MyndPhlyp wrote: "Carlis" <li****@carlosg rima.com> wrote in message news:If******** *************** @telenews.telel ine.es...
Very thanks Michel for your detailed response.
Im very surprised about the amount of things that have changed in plane
HTML
and JavaScript... For example: the label <b> deprecated!!!! :-S
<B> is depreciated? According to my copy of the HTML 4.01 Specifications it isn't. <FONT> and <BASEFONT> are depreciated, as are <STRIKE>, <S> and <U>, but <B> is definitely not indicated as depreciated.
Is there a newer HTML Specification I am not aware of?
Neither HTML 4 nor XHTML 1.0 nor XHTML 1.1 deprecate the <b> element, I
guess Michael got a little bit carried away in an attempt to suggest to
use CSS for presentational aspects instead of HTML markup.
--
Martin Honnen http://JavaScript.FAQTs.com/
"Martin Honnen" <ma*******@yaho o.de> wrote in message
news:41******** *************** @newsread4.arco r-online.net...
MyndPhlyp wrote:
"Carlis" <li****@carlosg rima.com> wrote in message news:If******** *************** @telenews.telel ine.es...
Very thanks Michel for your detailed response.
Im very surprised about the amount of things that have changed in plane
HTML
and JavaScript... For example: the label <b> deprecated!!!! :-S
<B> is depreciated? According to my copy of the HTML 4.01 Specifications
it isn't. <FONT> and <BASEFONT> are depreciated, as are <STRIKE>, <S> and
<U>, but <B> is definitely not indicated as depreciated.
Is there a newer HTML Specification I am not aware of?
Neither HTML 4 nor XHTML 1.0 nor XHTML 1.1 deprecate the <b> element, I guess Michael got a little bit carried away in an attempt to suggest to use CSS for presentational aspects instead of HTML markup.
Thanks. For a minute there I was worried.
:::returning to the comfort and security under my rock:::
MyndPhlyp wrote: <B> is depreciated?
Is there a newer HTML Specification I am not aware of?
No, it falls into that group of elements known as "This is presentational,
why on earth wasn't it deprecated?!"
--
David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
On Sun, 14 Nov 2004 14:49:12 GMT, Carlis <li****@carlosg rima.com> wrote: Very thanks Michel for your detailed response.
You're welcome.
Im very surprised about the amount of things that have changed in plane HTML and JavaScript...
The points I made about nesting elements incorrectly have always held
true. Browsers will render them still, but the browser will have to
correct its internal representation to something more acceptable. The
problem with this, apart from making parsing slower, is that every browser
corrects documents differently. They may also "correct" it in such a way
that it breaks your page.
A recent example appeared in comp.infosystem s.www.authoring.html (ciwah).
The poster had something along the lines of:
<div>
<form ...>
[form controls]
</div>
<div>
<div>
[form controls]
</form>
</div>
<div>
<form ...>
[form controls]
</form>
</div>
</div>
Aside from the fact that it's "DIV soup", it's complete nonsense,
structurally. The first FORM begins in one DIV, ends in another. It would
be difficult for a user agent to correct that and keep its original
functionality.
For example: the label <b> deprecated!!!! :-S
Sorry, I was wrong there. The B element isn't deprecated, but it is
discouraged in favour of style sheets. See
<URL:http://www.w3.org/TR/html4/present/graphics.html#h-15.2>.
In general, any element or attribute that is purely presentational, such
as FONT and bgcolor, have been deprecated. After all, the intent of HTML
is not a means of presentation, but a way of describing what parts of
document actually are - what they mean.
I have already tested your script and it works perfectly, but i don't understand it a lot :-(
I have a tendency to be terse.
/* This function will modify the inline style sheet information
* for the given element. Specifically, it will set the font
* weight to the given value.
*
* The result is the equivalent of applying the attribute,
* style="font-weight: <value>;" to the element.
*/
function setWeight(eleme nt, value) {
/* First, we should check that the object reference to the
* element is a valid reference. Objects, other than null,
* evaluate to true when converted to a boolean.
*
* Second, we should check that the object supports the style
* object - our way of modifying its inline style information.
*/
if(element && element.style) {
/* If the previous tests pass, we can assign a new value. */
element.style.f ontWeight = value;
}
}
Now notice the values passed to the function:
onmouseover="se tWeight(this, 'bold');"
onmouseout="set Weight(this, '');"
The value, 'bold', will quite obviously set the font weight to bold, but
what about the empty string? This effectively removes any styling for that
property. With that gone, the element will revert to whatever style is
specified by the page style sheet.
I see i have to start studying HTML
It's mainly a matter of realising that HTML has rules. Many of them are
common sense, like a nested element should be completely contained
<form>
<div>
</div>
</form>
not
<form>
<div>
</form>
</div>
and that certain elements may only contain certain other elements.
Learning this is just a matter of time. Regularly validating your pages
(using the link I gave in my last post) should give you a feel for what's
correct, and what's not.
Due to error correction in browsers, it seems that many people think you
can write any old rubbish and everything will work perfectly. Whilst what
an author has written may be fine for a particular browser, they often
haven't tested it on many other browsers where their page will go horribly
wrong. A lot of people still think that IE and Netscape are the only
browsers in the world. Some only know the former exists.
and JavaScript [...]
Javascript, the language, hasn't changed that much. It's the document
object model (DOM) that browsers expose to scripts that has come a long
way.
The documentation of HTML, JavaScript and DHTML that i have is from 1998
That is quite out-of-date, though HTML 4.01 (the most recent version) only
became a Recommendation in '99.
(i don't attach it because it is 3 megas, but i can send to you if you want).
If you had attached it, my news server would have rejected your post
entirely. It was a good thing you didn't.
You should never send attachments, which includes sending HTML-based
messages, to Usenet (unless you're posting to a binary group).
Anyway, may be if i use your suggestions the web could not work in old versions of Explorer or Netscape.
According to Microsoft, that code should work in IE 4, but I can't test
that. As for NN 4, very little will work there. A growing opinion is that
NN 4 is dead and attempting to support it is a wasted effort.
[snip]
As far as resources go, I'm not really the person to ask.
The FAQ for this group (<URL:http://jibbering.com/faq/>) contains some
links, and plenty of its own advice with regard to Javascript.
As for HTML, try <URL:http://www.html-faq.com/>, and
<URL:http://www.htmlhelp.co m/> seems to come better recommended than
<URL:http://www.w3schools.c om/>.
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
On Sun, 14 Nov 2004 16:15:16 +0100, Martin Honnen <ma*******@yaho o.de>
wrote:
[snip] I guess Michael got a little bit carried away in an attempt to suggest to use CSS for presentational aspects instead of HTML markup.
Unfortunately, yes. I tend to consider everything in section 15 of the
Recommendation (15 - Alignment, font styles, and horizontal rules) as
deprecated. It is, pretty much.
I provided a retraction in my other post.
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Hello Mike :-)
Thanks for all explanations and the final links. You have been really nice
with me, so we can drink some beer together one day (I'll pay of course) :-D
--
CARLOS GRIMA
· Personal Web: www.carlosgrima.com
· Email & MSN: ca*********@car losgrima.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mark4asp |
last post by:
Why won't the window.status message change ?
IE ver. 6.0.2800.1106 displays the tooltip OK.
<td>
<A HREF="editAuthor.asp?item=4"
title="Edit author details"
onMouseOver="window.status=this.title"
onMouseOut="window.status=''">Micky Mouse</A>
</td>
|
by: Victor Martin |
last post by:
Bold text in proportional fonts use up more space than non-bold text.
Is there a way to keep the space bold takes up within the limits of the
regular text while keeping the same font?
|
by: Frances Del Rio |
last post by:
on pop-up, which I have scripted to not show status bar, status bar
still shows up in Firefox. Any way to get Firefox to open pop-ups w/o
status bar at the bottom? thank you.. Frances
|
by: Brian Henry |
last post by:
I thought this was useful, its a extender i just wrote for the new .NET menu
strip and status strip to extend the menu items to add a status message so
when a mouse rolls over the item it displays the text on the status strip
lable specified for the extender.. all you have to do is copy this to a code
file, and add it as a control to your form. set the status lable property of
the extender control then set the status mesages of the menu...
|
by: NielsM |
last post by:
Hello All,
Found a bit of Javascript on this forum that shows the title-text of a
link in the statusbar, so you don't have to type
onmouseover="window.status='bla di bla'" in every link.
http://groups.google.nl/group/comp.lang.javascript/browse_thread/thread/16906e69836826c3/4922a5c1a40fd2a1
But it does not show the title when the link (<a href=""..>text</a>)
is in a DIV tag.
| |
by: mistral |
last post by:
Is there some other (more advanced) effects for status bar, other than
standard Scroller Bar, TypeWriter Scroller, Flashing Bar, Decrypter,
Ticker, World Clock?
|
by: Ramesh |
last post by:
Hello,
I am using the ofstream class to create a text file with keys and
values like:
Key1=Value10
Key2=Value15
Key3=Value20
In case I need to set a new value for Key2, say value50 - I am able to
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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,...
|
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...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
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
|
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 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...
| |