Link to home
Start Free TrialLog in
Avatar of cavacasp
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.ShockwaveFlash.3"))
if flashmode=false then
flashmode = isobject (createobject ("ShockwaveFlash.ShockwaveFlash.4"))
end if
if flashmode=false then
location.pathname="default6.htm"
end if
end function
-->
</script>
Avatar of Mark Franz
Mark Franz
Flag of United States of America image

So you are running Netscape for your web server?
Avatar of DreamMaster
DreamMaster

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.indexOf('Mac')!=-1);
  var versie = parseInt(navigator.appVersion);

  if (IsMac && IsExplorer) location.href='whereeverto.html';
  if (IsNetscape && versie >= 4)
    CheckPlugin('Shockwave Flash','flashpage.html','nonflashpage.html',true)
  if (IsNetscape && versie < 4)
    CheckPlugin('Shockwave Flash','','',true)

  else if (IsExplorer)
  {
     if (versie >= 4)
       IEdetected();
     else
       location.href='smartsite.asp?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.indexOf('Mac') == -1 &&
       navigator.appVersion.indexOf('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...
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.ShockwaveFlash.3"))
if flashmode=false then
flashmode = isobject (createobject ("ShockwaveFlash.ShockwaveFlash.4"))
end if
if flashmode=false then
location.pathname="default6.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




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...


Avatar of cavacasp

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
Avatar of DreamMaster
DreamMaster

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yippie!!!!