• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

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>
0
cavacasp
Asked:
cavacasp
  • 4
  • 3
  • 2
  • +1
1 Solution
 
mgfranzCommented:
So you are running Netscape for your web server?
0
 
DreamMasterCommented:
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...
0
 
JagarCommented:
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.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
JagarCommented:
No IIS on the Web Server.  The problem is Netscape clients.
0
 
mgfranzCommented:
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




0
 
JagarCommented:
I know and this is running client side to check ans see if the user has the Player installed on the local PC.
0
 
DreamMasterCommented:
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...


0
 
cavacaspAuthor Commented:
OK everything else looks good.  I'm pretty sure I understand the rest of it, so post an answer and I'll accept it.
0
 
DreamMasterCommented:
ok...here goes!

thanks!
0
 
DreamMasterCommented:
Yippie!!!!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now