cavacasp
asked on
Converting VBScript to JavaScript
I have the following piece of code that was written in VBScript, but of course Netscape doesn't like VBScript and only works with JavaScript. So I need somebody who can convert this script into JavaScript so that it will work in both IW and Netscape
<script language="vbscript">
<!--
function window_onload ()
on error resume next
var flashmode
flashmode = isobject (createobject ("ShockwaveFlash.Shockwave Flash.3"))
if flashmode=false then
flashmode = isobject (createobject ("ShockwaveFlash.Shockwave Flash.4"))
end if
if flashmode=false then
location.pathname="default 6.htm"
end if
end function
-->
</script>
<script language="vbscript">
<!--
function window_onload ()
on error resume next
var flashmode
flashmode = isobject (createobject ("ShockwaveFlash.Shockwave
if flashmode=false then
flashmode = isobject (createobject ("ShockwaveFlash.Shockwave
end if
if flashmode=false then
location.pathname="default
end if
end function
-->
</script>
So you are running Netscape for your web server?
looks like You're trying to detect Flash... You can use it as follows...
Write a browser detection script...
<script language="Javascript">
<!--
var AppName = navigator.appName;
var IsExplorer = AppName.indexOf("Microsoft ")!=-1;
var IsNetscape = AppName.indexOf("Netscape" )!=-1;
var IsMac = navigator.platform && (navigator.platform.indexO f('Mac')!= -1);
var versie = parseInt(navigator.appVers ion);
if (IsMac && IsExplorer) location.href='whereeverto .html';
if (IsNetscape && versie >= 4)
CheckPlugin('Shockwave Flash','flashpage.html','n onflashpag e.html',tr ue)
if (IsNetscape && versie < 4)
CheckPlugin('Shockwave Flash','','',true)
else if (IsExplorer)
{
if (versie >= 4)
IEdetected();
else
location.href='smartsite.a sp?id=844' ;
}
//-->
</script>
Then for Netscape....
<script language="JavaScript">
<!--
function CheckPlugin(plugin, theURL, altURL, IEGoesToURL) { //v2.0
if ((navigator.plugins && navigator.plugins[plugin]) || //if NS, or
(IEGoesToURL && //if flag set, and MSIE browser for Win95/NT (ActiveX)
navigator.appName.indexOf( 'Microsoft ') != -1 &&
navigator.appVersion.index Of('Mac') == -1 &&
navigator.appVersion.index Of('3.1') == -1)) {
if (theURL.length>2) window.location = theURL;
} else {
if (altURL.length>2) window.location = altURL;
}
document.MM_returnValue = false;
}
//-->
</script>
That's the function NS uses..You could send IE to Your VB function...i send it to a function called IEDetected, which was also VB, so this should help You...
i hope this is helpfull...if You don't understand anything just ask...
Write a browser detection script...
<script language="Javascript">
<!--
var AppName = navigator.appName;
var IsExplorer = AppName.indexOf("Microsoft
var IsNetscape = AppName.indexOf("Netscape"
var IsMac = navigator.platform && (navigator.platform.indexO
var versie = parseInt(navigator.appVers
if (IsMac && IsExplorer) location.href='whereeverto
if (IsNetscape && versie >= 4)
CheckPlugin('Shockwave Flash','flashpage.html','n
if (IsNetscape && versie < 4)
CheckPlugin('Shockwave Flash','','',true)
else if (IsExplorer)
{
if (versie >= 4)
IEdetected();
else
location.href='smartsite.a
}
//-->
</script>
Then for Netscape....
<script language="JavaScript">
<!--
function CheckPlugin(plugin, theURL, altURL, IEGoesToURL) { //v2.0
if ((navigator.plugins && navigator.plugins[plugin])
(IEGoesToURL && //if flag set, and MSIE browser for Win95/NT (ActiveX)
navigator.appName.indexOf(
navigator.appVersion.index
navigator.appVersion.index
if (theURL.length>2) window.location = theURL;
} else {
if (altURL.length>2) window.location = altURL;
}
document.MM_returnValue = false;
}
//-->
</script>
That's the function NS uses..You could send IE to Your VB function...i send it to a function called IEDetected, which was also VB, so this should help You...
i hope this is helpfull...if You don't understand anything just ask...
If you don't mind can you walk through the code for me. There are some parts that I don't understand for example what is wherever.htm and some other parts.
No IIS on the Web Server. The problem is Netscape clients.
Unless you are trying to run .asp code client side, there is no issue of running vbscript on the server to process server apps.
To run server side;
<HTML>
<head>
<%
function window()
on error resume next
var flashmode
flashmode = isobject (createobject ("ShockwaveFlash.Shockwave Flash.3"))
if flashmode=false then
flashmode = isobject (createobject ("ShockwaveFlash.Shockwave Flash.4"))
end if
if flashmode=false then
location.pathname="default 6.htm"
end if
end function
%>
<BODY onload="window()" >
You need to differentiate between server-side & client side.
http://msdn.microsoft.com/training/free/mwd64/mwd9800334.htm
Mark
To run server side;
<HTML>
<head>
<%
function window()
on error resume next
var flashmode
flashmode = isobject (createobject ("ShockwaveFlash.Shockwave
if flashmode=false then
flashmode = isobject (createobject ("ShockwaveFlash.Shockwave
end if
if flashmode=false then
location.pathname="default
end if
end function
%>
<BODY onload="window()" >
You need to differentiate between server-side & client side.
http://msdn.microsoft.com/training/free/mwd64/mwd9800334.htm
Mark
I know and this is running client side to check ans see if the user has the Player installed on the local PC.
ok Jagar...
the whereeverto.html is a page You might load to avoid browsers that don't have flash or don't know how to detect it, where to go..for example in the browser detection You see
if (IsMac && IsExplorer) location.href='whereeverto .html';
Detects whether a Macintosch with IE is used if so it goes to whatever.html because IE on the Mac has no way of detecting Flash.
Whatelse don't You understand?
just let me know and i'll help You...it's not that hard at all...
the whereeverto.html is a page You might load to avoid browsers that don't have flash or don't know how to detect it, where to go..for example in the browser detection You see
if (IsMac && IsExplorer) location.href='whereeverto
Detects whether a Macintosch with IE is used if so it goes to whatever.html because IE on the Mac has no way of detecting Flash.
Whatelse don't You understand?
just let me know and i'll help You...it's not that hard at all...
ASKER
OK everything else looks good. I'm pretty sure I understand the rest of it, so post an answer and I'll accept it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yippie!!!!