Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > javascript pseudo-protocol and event handlers

Reply
Thread Tools

javascript pseudo-protocol and event handlers

 
 
yawnmoth
Guest
Posts: n/a
 
      06-23-2006
I've seen a few webpages that use the javascript pseudo-protocol with
event handlers. eg.

<input onkeyup="javascript: ..." />

Correct me if I'm wrong, but isn't onkeyup always supposed to be
javascript, anyway? As such, isn't usint hte javascript
pseudo-protocol redundant?

....or was it required on some archaic browser like Netscape 4.0 or
something?

 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      06-23-2006
yawnmoth said the following on 6/23/2006 4:41 PM:
> I've seen a few webpages that use the javascript pseudo-protocol with
> event handlers. eg.
>
> <input onkeyup="javascript: ..." />


Usually because they don't know better. Or, they are using VBScript in
the same page.

> Correct me if I'm wrong, but isn't onkeyup always supposed to be
> javascript, anyway? As such, isn't usint hte javascript
> pseudo-protocol redundant?


Depending on whether it is IE or not and what the default script
language in the page is.

> ....or was it required on some archaic browser like Netscape 4.0 or
> something?


No.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices -
 
Reply With Quote
 
 
 
 
Matt Kruse
Guest
Posts: n/a
 
      06-23-2006
yawnmoth wrote:
> Correct me if I'm wrong, but isn't onkeyup always supposed to be
> javascript, anyway? As such, isn't usint hte javascript
> pseudo-protocol redundant?


Kind of redundant, but in reality it's a completely different meaning that
uses the same syntax by chance.

In an example like
<input onkeyup="javascript: ..." />

the "javascript:" is acting as a label, which is allow in javascript code.
So it doesn't create an error, even thouh it serves no purpose and is surely
caused by someone not understand what the javascript: pseudo-protocol is and
where it (used to) be used.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com


 
Reply With Quote
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      06-24-2006
"yawnmoth" <(E-Mail Removed)> writes:

> I've seen a few webpages that use the javascript pseudo-protocol with
> event handlers. eg.
>
> <input onkeyup="javascript: ..." />
>
> Correct me if I'm wrong, but isn't onkeyup always supposed to be
> javascript, anyway?


It's supposed to be the script langauge set as the Content-Script-Type
(e.g., <meta http-equiv="Content-Script-Type" content="text/javascript">)
but all browsers default to Javascript if nothing else is specified.

In IE, it's possible to have a default language of VBScript. In order
to allow event handlers in Javascript anyway, the prefix "javascript:"
will make IE treat the content as Javascript independently of what
the default language is.

In all other browsers it's just a label, which can be seen by this
example:
<div onclick="javascript:while(true){break javascript;}alert('done')">
X</div>
click the X and see an alert in non-IE browsers and an error in IE
(unknown label).

> As such, isn't usint hte javascript pseudo-protocol redundant?


If that was what it meant, it would be redundant. Actually, it's just
misguided.

> ...or was it required on some archaic browser like Netscape 4.0 or
> something?


No, never. The only place where it has any use is in multi-script-
language pages written specifically for IE. In a page meant for the
internet, any occurence of "javascript:" should be considered a
problem[1]

/L
[1] Unless you are showing off your bookmarklets.
--
Lasse Reichstein Nielsen - http://www.velocityreviews.com/forums/(E-Mail Removed)
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Firefox differences in event handlers through HTML attributes and Javascript DOM Safalra Javascript 2 03-30-2007 03:48 AM
JavaScript Experts, How Do I Debug This Event Handlers Problem? Ray Javascript 5 03-07-2007 09:58 PM
attaching event handlers to tags with javascript yawnmoth Javascript 2 12-24-2005 08:40 AM
Confused by a javascript problem, event handlers not working as expected/desired Deryck Javascript 7 12-02-2004 06:21 PM
About Event Handlers, Delegates and Scopes Alex MCSD 6 05-21-2004 01:49 AM



Advertisments