473,396 Members | 1,996 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,396 software developers and data experts.

A tag: href vs. onClick

See

<ul>
<li><a name="link1" onClick="alert(this.name);return false;"
href="#">Link1</a></li>
<li><a name="link2" href="javascript:alert(this);">Link2</a></li>
<li>Item 3</li>
</ul>

Clicking on the first list item gives me "link1" because "this" refers
to the A node so this.name returns the value of the name attribute of
that node.

But in the second link, "this" seems to refer to the window node!

Why is this? Why does the meaning of "this" change so drastically when
used in a href=javascript: vs. a onClick=

Thanks

Oct 23 '05
53 81642
VK
> >>VK said the following on 10/26/2005 5:56 PM:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<script type="text/vbscript">
Dim MyVar
MyVar = MsgBox ("Hello World!", 216, "MsgBox Example")
' MyVar contains either 1 or 2, depending on which button is clicked.
</script>
</head>
<body>
<P>This is the body of the document</P>
<noscript>
<P>You have scripting disabled</P>
</noscript>
</body>
</html>


I did not get that I guess. On both Opera 8.01 and FireFox 1.0.7 it
ignores VBScript and shows "This is the body of the document" line only
in the body. What's wrong with that?

Randy Webb wrote:

It does not support the script. So, in theory, it should show the
noscript element but it doesn't.

But it does support *the* script! Try <body onload="alert('I support
scripting')">

It simply ignores fragment of unknown Content-Type "text/vbscript"
which seems right to me (?)

If VBScript was a part of common Web standards we would expect 3
separate tags from W3C like:
<NOJSSCRIPT>
<NOVBSCRIPT>
<NOANYSCRIPT>
Otherwise single <NOSCRIPT> is sufficient (?)

If anyone puts her nose out of the ASP box to the client-side, it's her
duty to provide a roll-back for standard browser users.

<script type="text/vbscript">
// Code
</script>
<script type="text/javascript">
// Warning message if VBScript
// was not executed
</script>
P.S. Ave we advocation VBScript ? ;-)

Oct 28 '05 #51
VK

VK wrote:
P.S. Ave we advocation VBScript ?


Wow! Lesser beer - more sport! ;-)

P.S. Are we advocating VBScript?

Oct 28 '05 #52
VK
Formally thinking over the "VBScript is here but JavaScript is not"
issue we should insist on proper META-EQUIV declaration for used
language as suggested by W3C:
<http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.2.1>
(that was not nice of you to force me to go into Triple-W docs :-)

Naturally it still fails if a language cocktail (VBScript/JScript) is
used on the same page. But in case of VBScript-only it would prevent
script error in the sample below *if it was implemented by anyone*. But
neither of browsers I know of (including FireFox) doesn't respect this
content header.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Testcase</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<meta http-equiv="Content-Script-Type" content="text/vbscript">
<style type="text/css">
<!--
body { background-color: #FFFFFF}
-->
</style>

<script>
Function vbsFunction()
Dim Foo
Foo = MsgBox("VBScript Message Box",64,"Test")
End Function
</script>
</head>

<body onload="vbsFunction()">
<p>No content</p>
</body>
</html>

Oct 28 '05 #53
VK wrote:
Formally thinking over the "VBScript is here but JavaScript is not"
issue we should insist on proper META-EQUIV declaration for used
language as suggested by W3C:
<http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.2.1>
(that was not nice of you to force me to go into Triple-W docs :-)
The MS script engine, which is to my knowledge the only one to support
client-side VBScript, ignores the proper default scripting language
declaration via `meta' element. Instead, it selects the scripting
language in event handler attribute values based on the previously
selected scripting language or a label at the beginning of the event
handler attribute value.
Naturally it still fails if a language cocktail (VBScript/JScript) is
used on the same page. But in case of VBScript-only it would prevent
script error in the sample below *if it was implemented by anyone*. But
neither of browsers I know of (including FireFox) doesn't respect this
content header.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
To not let Quirks/Compatibility Mode be used by UAs with DOCTYPE switch
feature, a proper system identifier (DTD URL) is missing here.
[...]
<style type="text/css">
<!--


Trying to comment out the contents of `style' and `script' elements for UAs
is an obsolete practice in HTML and error-prone in XHTML. Both elements
have already been defined in HTML 3.2 (even if only as placeholders), and
even older specified versions of HTML are (marked as) obsolete by RFC.
PointedEars
Oct 28 '05 #54

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

Similar topics

6
by: Skip Hollowell | last post by:
I am working on a menu bar for a site, and am using buttons in the bar (because the customer wants to use accessKeys for each selection, apparently it is too much work to click on them with a...
1
by: Mosher | last post by:
Hi all, is there a good way to have a popup window appear using Javascript and the html "map" tag? Here is my code: <map name="navigation"> <area shape="rect" coords="5,57,45,70"...
6
by: hsomob1999 | last post by:
so i have a <ul> and I allow the user to append items to it. The problem is that on mozilla the <span class="line"> which is just a line to divide the sections gets overlaped and doesnt move down...
0
by: voidptr | last post by:
I wirte a table inside the div container but i see something weired.. table expands to right when there is no scroll bar on page..I mean there is slight mislalignment. Below is the sample code...
26
by: johkar | last post by:
I need to cancel the link and execute a function onclick of all the links within the span tag which has a class of "container" assigned. There will be only one span tag with this class applied. ...
11
by: GaryB | last post by:
Hi Guys, I've been battling with this one for hours - I hope that you can help me! My code modifies the <aon a page, from a standard document link into a link with a tailored onclick event. ...
1
by: garey | last post by:
Hello - I have written a small table of contents manager. If an entry has sub-entries, it has a plus in front of it. If the user clicks on the plus, the sub-entries are displayed. The table of...
1
by: praveenb000 | last post by:
Hi every one, I designed a web page, having horizontal menu using UL and LI tags; I need to be set rollover effect for a menu items. whenever user hover on a menu item, the entire...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
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,...
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...

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.