473,748 Members | 2,891 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Putting "javascript :" in front of code?

I see some code examples like this:

<DIV onmouseover="th is.style.backgr ound='blue'">

and other code examples like this:

<DIV onmouseover="ja vascript:this.s tyle.background ='blue'">

Which way is more proper? Or are both ways perfectly fine? Are there any
specifications that discuss when "javascript :" should be put in front of code?

Jul 20 '05
25 3737
Waaaaay back on 06-Dec-03 03:58:11, delerious said this about Putting "javascript :" in front of code?:
I see some code examples like this: <DIV onmouseover="th is.style.backgr ound='blue'"> and other code examples like this: <DIV onmouseover="ja vascript:this.s tyle.background ='blue'"> Which way is more proper? Or are both ways perfectly fine? Are there any
specificatio ns that discuss when "javascript :" should be put in front of
code?


The "javascript :" prefix, seriously, is a gift from Satan. It's horrible.
Most browsers I've used don't know what the fleeick to do with that.

If it works without the "javascript :" prefix, I say don't use it. If it
works WITH it, find an alternate way.

--
da****@banana-and-louie.org * dauber.50megs.c om
* ICQ: 28677921 * YIM: dau_ber * AIM: ddaauubbeerr

Jul 20 '05 #11
On Sat, 06 Dec 2003 15:00:01 +0100, Lasse Reichstein Nielsen <lr*@hotpop.com >
wrote:
Which way is more proper?


The former. Personally, I would write:
<div onmouseover="th is.style.backgr oundColor='blue ';">
but that's leaving correct and passing on to pedantic :)


Oh this was another thing I was wondering about. :) I tried to do
"this.style.bac kground-color='blue'" but got an error. So in order to get
those CSS properties to work in Javascript, I should remove the hyphens and
capitalize the first letter of the words after hyphens?

Thanks for the great, informative responses everyone!

Jul 20 '05 #12
de*******@no.sp am.com writes:
Oh this was another thing I was wondering about. :) I tried to do
"this.style.bac kground-color='blue'" but got an error. So in order to get
those CSS properties to work in Javascript, I should remove the hyphens and
capitalize the first letter of the words after hyphens?


Yes, that is the way CSS properties are mapped into Style Object
properties in the W3C DOM (and supported in most modern browsers).
<URL:http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSS2Properties>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #13
Jim Ley wrote on 06 Dec 2003:
On Sat, 06 Dec 2003 12:10:04 GMT, Michael Winter
<M.******@bluey onder.co.invali d> wrote:
For JavaScript, the MIME type is text/javascript, so the above
should read:


Could you cite the relevant RFC which indicates this please?
for JavaScript (capatilised like that) the relevant one would be
application/x-javascript surely?


The HTML specification itself uses text/javascript as the MIME type
for JavaScript (though that doesn't necessarily make it correct).

This issue was raised in W3C's public HTML mailing list two years ago
(http://lists.w3.org/Archives/Public/...Sep/0020.html). It
comments that then, various script MIME types (of both text and
application types) were not registered. Looking on IANA's website, I
found that they're /still/ not registered. Mentioned in that mailing
list was the fact that browsers are split on what types to use: IE
with text and Netscape with application. However, as neither types
have been registered, neither browser is correct. I don't know what
various browsers consider the proper JavaScript MIME type. However, I
do agree that an application type is the better choice.
If you omit either the header or META element, but use intrinsic
events, your HTML document is invalid.


No, invalid has a technical meaning in HTML, and that does not
make it invalid, it may make it a non-conforming HTML 4
document, but then that's only a tiny subset of HTML. ( RFC
2854 blesses all tag-soup to be html)


Do the semantics really matter? Yes, if you attempted to validate the
document it would succeed, but the document is still incorrect and
relies on behaviour that is not guaranteed.

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk")
Jul 20 '05 #14
Lee wrote on 06 Dec 2003:
Michael Winter said:

Richard Cornford wrote on 06 Dec 2003:
"Michael Winter" <M.******@bluey onder.co.invali d> wrote in
message
news:Xn******** *************** ********@193.38 .113.46...


<snip>
The second way is incorrect.

Incorrect might be a bit strong as it implies something
contrary to some criteria of validity or syntactic
correctness. Though that may just be a matter of
interpretation (of English).


Incorrect, meaning: the wrong way of specifying the language of
an intrinsic event.


The OP didn't ask how to specify the language, he asked
which syntax was more proper.


I know what the OP asked.
That's true, but the topic isn't (quite) relating to JavaScript
source code. This is regarding the use of the string,
"javascript:" , to actually perform some specific action.


That's not how I interpret the topic. I suspect the OP
didn't know that other languages were even available.


The original question was: Is "javascript:som e_javascript_co de"
syntactically correct? The answer is yes. But leaving it at that
neglects the assumption upon which the inclusion of "javascript :" is
based. Some authors that post to this group attach a special meaning
to that string in an intrinsic event, and that association needs to
be dispelled.

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk")
Jul 20 '05 #15
Lee
Michael Winter said:
The original question was: Is "javascript:som e_javascript_co de"
syntacticall y correct? The answer is yes. But leaving it at that
neglects the assumption upon which the inclusion of "javascript :" is
based. Some authors that post to this group attach a special meaning
to that string in an intrinsic event, and that association needs to
be dispelled.


Certainly, but not by replacing it with the false belief that
it is incorrect JavaScript. The message that you responded
to had made the actual facts clear. You muddied the waters
by suggesting that his explanation was wrong.

Jul 20 '05 #16
On Sun, 07 Dec 2003 02:11:17 GMT, Michael Winter
<M.******@bluey onder.co.invali d> wrote:
Jim Ley wrote on 06 Dec 2003:
The HTML specification itself uses text/javascript as the MIME type
for JavaScript (though that doesn't necessarily make it correct).
Good for it, it has no change control or anything else over
javascript, The HTML WG has no more status than me or you on what is
the mime-type for js, you'll note the SVG WG say it's text/ecmascript.

However, as neither types
have been registered, neither browser is correct.
You don't seem to understand the x- tree, whilst you shouldn't use an
x-tree in public really, there we'ren't vnd. trees for it to go, there
is nothing wrong in using an x-tree.
I don't know what
various browsers consider the proper JavaScript MIME type. However, I
do agree that an application type is the better choice.


No it's not, it's a private namespace for development/experimental
purposes and should only be used by agreement of what it means at
boths ends, that's never happened. x-trees should not be used on the
web, and they should not be used at all now (the vnd. and prs. trees
are better for what it achieves)
If you omit either the header or META element, but use intrinsic
events, your HTML document is invalid.


No, invalid has a technical meaning in HTML, and that does not
make it invalid, it may make it a non-conforming HTML 4
document, but then that's only a tiny subset of HTML. ( RFC
2854 blesses all tag-soup to be html)


Do the semantics really matter?


Yes, the meaning of VALID matters, the more important fact though is
it is only HTML 4 where the above rules come into play, as most people
author tag-soup, or other HTML types, the rules do not exist.

Jim.
--
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #17
Jim Ley wrote on 07 Dec 2003:
On Sun, 07 Dec 2003 02:11:17 GMT, Michael Winter
<M.******@bluey onder.co.invali d> wrote:
Jim Ley wrote on 06 Dec 2003:
The HTML specification itself uses text/javascript as the MIME
type for JavaScript (though that doesn't necessarily make it
correct).
Good for it, it has no change control or anything else over
javascript, The HTML WG has no more status than me or you on
what is the mime-type for js, you'll note the SVG WG say it's
text/ecmascript.


That's why I said: "though that doesn't necessarily make it correct".
I realise that they have no say over the MIME type for JS. However, I
would of thought that they made the decision to use that type in
their specifications for a good reason.

<snip>
I don't know what
various browsers consider the proper JavaScript MIME type.
However, I do agree that an application type is the better
choice.


No it's not, it's a private namespace for
development/experimental purposes and should only be used by
agreement of what it means at boths ends, that's never happened.
x-trees should not be used on the web, and they should not be
used at all now (the vnd. and prs. trees are better for what it
achieves)


Where in that paragraph (specifically that last sentence) do I
mention application/x-javascript?
Yes, the meaning of VALID matters, the more important fact
though is it is only HTML 4 where the above rules come into
play, as most people author tag-soup, or other HTML types, the
rules do not exist.


As you say, most people write tag soup. It stands to reason that most
wouldn't understand (or care about) the distinction between invalid
and incorrect. I used 'invalid' as a synonym of wrong. It didn't
occur to me at the time that it could be interpreted any other way.
It is for that reason that I refer (and anticipate references) to
validation of a HTML document explictly.

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk")
Jul 20 '05 #18
On Sun, 07 Dec 2003 13:31:41 GMT, Michael Winter
<M.******@bluey onder.co.invali d> wrote:
That's why I said: "though that doesn't necessarily make it correct".
I realise that they have no say over the MIME type for JS. However, I
would of thought that they made the decision to use that type in
their specifications for a good reason.
Such as? - If the reason is "it's what works in current UA's" then
others are free to argue that the defaulting to ecmascript for
intrinsic events is just as legitimate.
Where in that paragraph (specifically that last sentence) do I
mention application/x-javascript?


sorry, I misread an "an" for a "the" there, and thought you were
talking about the x-javascript one.

Jim.
--
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #19
Jim Ley wrote:
Michael Winter wrote:
The HTML specification itself uses text/javascript as the MIME type
for JavaScript (though that doesn't necessarily make it correct).
Good for it, it has no change control or anything else over
javascript,


It is used in the Recommendation because it is widely supported.
The HTML WG has no more status than me or you on what is the mime-type
for js, you'll note the SVG WG say it's text/ecmascript.


You know that text/ecmascript targets a different language. Besides,
that is not standardized as well. Since the W3C does not watch over
either ECMAScript or JavaScript, as you wrote before (but ECMA does),
one of W3C's working groups is not the appropriate standardization
board to decide what is the proper MIME type for JavaScript. And last
but not least, what about

http://lists.w3.org/Archives/Public/...2Aug/0008.html

?
PointedEars
--
The Internet is filled with people trying to make a name for themselves by
breaking your code, crashing your site, posting inappropriate content, and
otherwise making your day interesting. (from: The PHP manual, 5. Security)
Jul 20 '05 #20

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

Similar topics

6
9938
by: Yvan J. Gagnon | last post by:
I am currenly developing a web site using Macromedia fireworks, and am trying to figure out a way (through hand-coding) of attaching a javascript function (onClick="doit=false") to each of the links in my fireworks-generated dhtml popup menus. Does anyone here know where I would add this javascript fucntion in the code so that it would be recognized? And do I do it in the html, or in the JS file? The javascript function I need to add is...
9
13426
by: David D. | last post by:
Does the file extension matter when including a JavaScript file in an HTML page? Normally, one would include a JavaScript file in an HTML page using <script src="foo.JS" type="text/javascript"> However, I have found that I can use an alternate file extension, such as <script src="foo.HTML" type="text/javascript"> It works fine with my IE 6 and Mozilla. Will it work with other browsers?
3
1954
by: TC | last post by:
Hello, I am using the script below to open a new window and once opened, redirect to that open window from the original window: private void btnNewPDFWindow_Click(object sender, System.EventArgs e) { string NewPage = "NewPageZoom.aspx";
1
2406
by: Slavo Smutny | last post by:
Hi, which is better approach to store my JavaScript code, to store it in separate .js file or to embed the code within HTML attributes (e.g. <p onclick="javascript:submit();">click this</p>)? I am interested in performance, i.e. how quick is page loaded in each case? I think the better one is to store the code in separate .js file so that the user browser can cache the file (source: http://www.quirksmode.org/js/placejs.html#link1) but...
2
3162
by: TastyKarma | last post by:
Was hoping somebody might have experienced this before. I have client-side javascript in my aspx files. For some reason when I place the "debugger;" keyword in my javascript, Visual Studio no longer breaks into the code. It used to, and I can't figure out what could have changed to disable the feature. 1. My javascript code is definitely being called. 2. The "Disable Script Debugging" checkbox is cleared in my internet settings (I've...
3
1622
by: kaston3 | last post by:
I use screen.width to check escreen resolution and then document.write to write different width tables accordingly. It all works OK with Mozilla Firefox, however it seems that in IExplorer it only works when I reload the page. I think it can be cache handling in IE. I tried putting the javascript code in an extrenal js.file. Then i tried calling that file with a random number (using time functions) eg. mycode.js?nn=secondss; but it...
1
2694
by: morgan.chengmo | last post by:
Hi, I am wandering whether all javascript code in one page is executed in one thread. I know that javascript has no threading mechansim. No way to tell which thread is running by code iteself. For below code <html> <head> </head>
10
539
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I protect my javascript code? ----------------------------------------------------------------------- With clientside Javascript you can't as your code is distributed in source form and is easily readable. With JScript, there is the Script Encoder (see MSDN), but this is nothing more than obfuscation. Disabling the right mouse button also does...
2
4396
drhowarddrfine
by: drhowarddrfine | last post by:
When I visit this board, I see this frequently: <script language=javascript> but "language=javascript" was deprecated in 1996. So, why do people still use it? It doesn't do anything.
0
8987
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
8826
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9534
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, 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...
0
9366
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...
0
9241
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...
1
6793
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
6073
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();...
0
4597
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...
1
3303
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 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.