Results 1 to 6 of 6

Thread: Could Anyone Convert this JScript to VBScript please

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2003
    Location
    South Yorkshire, England
    Posts
    52

    Wink Could Anyone Convert this JScript to VBScript please

    I am just learning VB and VBScript. I came accross a nice piece of code written in jscript... since I do not know a word of that could someone please convert the following to VBScript?
    Code:
    function setActiveCSS(title){var i,a,main;for(i=0;(a =document.getElementsByTagName("link")[i]);i++){if(a.getAttribute("rel").indexOf("style")!=-1&&a.getAttribute("title")){a.disabled=true;if(a.getAttribute("title")==title)a.disabled=false;}}}
    
    function getActiveCSS(){var i,a;for(i=0;(a=document.getElementsByTagName("link")[i]);i++){if(a.getAttribute("rel").indexOf("style")!=-1&&a.getAttribute("title")&&!a.disabled)return a.getAttribute("title");}return null;}
    
    function getPreferredCSS(){var i,a;for(i=0;(a=document.getElementsByTagName("link")[i]);i++){if(a.getAttribute("rel").indexOf("style")!=-1&&a.getAttribute("rel").indexOf("alt")==-1&&a.getAttribute("title"))return a.getAttribute("title");}return null;}
    
    function setCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires=";expires="+date.toGMTString();}else expires="";document.cookie=name+"="+value+expires+"; path=/";}
    
    function getCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}return null;}
    window.onload=function(e){var cookie=getCookie("css");var title=cookie?cookie:getPreferredCSS();setActiveCSS(title);}
    window.onunload=function(e){var title=getActiveCSS();setCookie("css",title,512);}
    TIA
    Last edited by Programmer_n00b; Jul 3rd, 2003 at 09:54 PM.
    Is the answer 42?
    -----BEGIN GEEK CODE BLOCK-----
    Version: 3.1
    GCS/O dpu(-)@ s++:+ a-->? C+++>--@ UL>B++++ P+>++++ L+(--) E--- W++>+++ N
    o? K- w+++>+++++$ O--->---- M->-- V? PS+ PE Y? PGP--- t+(-) 5? X-(++) R*
    tv++>! b+ DI+++>++++>+++++ D++ G>+++ e*>+++++ h!(*)>++ r%>$ x+>$
    ------END GEEK CODE BLOCK------

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Looks like client-side code to me. Why on earth would you want to convert it to VBScript?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2003
    Location
    South Yorkshire, England
    Posts
    52
    I thought you could run VBScript client side by using the;

    <script type="text/vbscript">
    blah blah
    </script>

    tags
    Is the answer 42?
    -----BEGIN GEEK CODE BLOCK-----
    Version: 3.1
    GCS/O dpu(-)@ s++:+ a-->? C+++>--@ UL>B++++ P+>++++ L+(--) E--- W++>+++ N
    o? K- w+++>+++++$ O--->---- M->-- V? PS+ PE Y? PGP--- t+(-) 5? X-(++) R*
    tv++>! b+ DI+++>++++>+++++ D++ G>+++ e*>+++++ h!(*)>++ r%>$ x+>$
    ------END GEEK CODE BLOCK------

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Originally posted by Programmer_n00b
    I thought you could run VBScript client side by using the;

    <script type="text/vbscript">
    blah blah
    </script>

    tags
    What CornedBee means is that you don't need to. it is fine exactly as it is as javascript. Even Microsoft is getting away from VBScript for web pages.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    And no browser beside IE supports it in the first place.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6
    Addicted Member TheAlchemist's Avatar
    Join Date
    Jan 2003
    Location
    Dar-esSalaam,Tanzania
    Posts
    139
    that code works pretty well,
    i use it myself...if you want to move from vbscript tp javascript or just learn javascript and other web related technologies go

    here
    One thing that sustains me through life is the conciousness of the immense inferiority of everyone else
    --Oscar Wilde

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width