Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts

    rewrite VBscript to javascript

    Hello, need a short vbscript rewrite into JavaScript:

    Code:
    <SCRIPT language="VBScript">
     If right(WINDOW.PARENT.topmenubar.LOCATION,11) = "menubar.asp" then
       'It is OK
     Else
       window.open "menubar.asp", "topmenubar"
     End If
    </SCRIPT>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,610
    Thanks
    78
    Thanked 4,387 Times in 4,352 Posts
    Code:
    <script type="text/javascript">
    var menuloc = window.parent.topmenubar.location;
    if ( menuloc.substring( menuloc.length - 11 ) == "menubar.asp )
    {
        // okay
    } else {
        window.open( "menubar.asp", "topmenubar" );
    }
    </script>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    eugene.garan (06-17-2013)

  • #3
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thank you. Also while waiting I done some research and found this to work as well:

    Code:
    if (window.parent.topmenubar.location.href.indexOf('menubar.asp')<0)  {
      parent.topmenubar.location = 'menubar.asp';
    }
    let me know if you agree with that. thanks!!

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,610
    Thanks
    78
    Thanked 4,387 Times in 4,352 Posts
    Sure, but it's not quite the same thing.

    For example, that code would work if the actual URL was "menubar.asp?name=framitz" whereas the original *INSISTS* that the string END with 'menubar.asp".

    So that code is more flexible, but it is not an exact replacement.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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