Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

VBScript need in Javascript instead for Mozilla comp.

I have two simple vbscripts that I need a javascript equivelent in order to
make compatible with Mozilla/Opera and other browsers.

Below are the two scripts and I wanted to do the same thing in Javascript.

<script language="VBScript" type="text/vbscript">
Sub ChangeStyle()
set el = window.event.srcElement
Select Case el.ClassName
case "cellframe"
el.ClassName = "cellframeover"
case "cellframeover"
el.ClassName = "cellframe"
End Select
End Sub

Sub GoThere()
set el = window.event.srcElement
If instr(3,el.id,".") Then
strLocation = el.id
Else
strLocation = el.id & ".asp"
End IF
parent.location.href = strLocation
End Sub
</script>

Any help in convertion is appreciated.

Johsua
[813 byte] By [Joshua] at [2007-11-9 17:50:52]
# 1 Re: VBScript need in Javascript instead for Mozilla comp.
> I have two simple vbscripts that I need a javascript
> equivalent in order to make compatible with Mozilla/Opera
> and other browsers.

Joshua: I can't guarantee that these will work the same in Mozilla/Opera
(their DOM implementations may differ from IE's), but the JavaScript should
be equivalent:

function changeStyle() {
var el = window.event.srcElement;
switch case(el.ClassName) {
case "cellframe" :
el.ClassName = "cellframeover"
break
case "cellframeover" :
el.ClassName = "cellframe"
}
}

function goThere() {
var el = window.event.srcElement;
if (el.id.substring(2, el.id.length).indexOf(".")) {
strLocation = el.id;
} else {
strLocation = el.id + ".asp";
}
parent.location.href = strLocation;
}

--
Phil Weber
Phil Weber at 2007-11-11 23:16:45 >