PDA

View Full Version : may sound stupid


chrismiceli
09-27-2002, 02:19 AM
this may sound stupid but why do people do stuff like this in javascript, i have been writing for a while and never found need to do it yet.

function hi() {
alert("hi")
}
<input type="button" value="new" onClick="javascript:hi()">

joh6nn
09-27-2002, 02:26 AM
there are two reasons why you might do that.

the first reason, is that you have no clue what you're doing. you copy and paste things, and hope that it works.

the second reason, is because you not only know what you're doing, but you know what your'e doing in both JavaScript and VBScript, use both languages on the same webpage, and want to make sure that the browser knows which function or sub you're referring, and doesn't go trying call your javascript function in VB, and doesn't try to run your vbscript sub in javascript.

jkd
09-27-2002, 02:49 AM
I'm pretty sure that a function written in Javascript is exposed to VBScript in IE.

There is no point in using the javascript: protocol in event handlers. Inside "href" though - that's a different story.

joh6nn
09-27-2002, 02:59 AM
jkd, check this out:

http://www.codingforums.com/ubb/Forum3/HTML/005318.html

Dave Clark discussed this down towards the bottom.