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

Need Javascript instead of VBScript

Can anybody help me - I need Javascript code, that perform same functions as VBScript (see below). Task is easy - there are some frames and I need change conents of one frame from another frame. In VBSCript I did it with Parent object. How can I do that with Javascript?
Sample (change page if language settings was changed in form):
Sub storeItem(item)
   Dim htmsource
   Dim lang
   htmsource=Parent.Frames("tsele").Document.Forms("myf").elements("itm").Value & lang &".htm"
End Sub

  • 2
  • 2
1 Solution
Try this, but be sure that all item names are in correct case.  JS is case sensitive.

Assumptions:  'tsele' is the name of the frame containing a form named 'MYF', which, in turn, has items named 'ITM' and 'LNG'.  'tclient' is another frame in the same frameset.

function storeItem(item) {
  var htmsource
  var lang
  parent.tsele.document.MYF.ITM.value = item
  lang = parent.tsele.document.MYF.LNG.value
  htmsource = parent.tsele.document.MYF.ITM.value + lang + ".htm"
  parent.tclient.location = htmsource

junior_bAuthor Commented:
Thanks, Tom! I find same way just few minutes before (I read Netscape manual on Web). In any case, you can post your comment as an answer (I check my solution with yours :-)). Only additional question - need I explicit define variables in Javascript or not?
By the way, don't you know, will this Javascript code work OK in any browser, or there is some browsers, that can't do that (I think, that VBScript is currently supported by most browsers, but it seems I was wrong. Is the same situation with Javascript?).
Thank you!

I don't think you need to explicitly define the variables in JS (but, then again, I don't think you need to define them explicitly in VBS either unless "option explicit" is specified).  It has never been an issue for me.

IMHO, your code will be 'safer' in JS.  There are some issues with the particular version of JS being used, but I think this particular code is pretty safe.  VBS is supported (currently) only by IE (as far as I know), JS is supported by virtually all the current generation of browsers (and several previous generations).

The only caveat to this is that JavaScript can be disabled at the client level.  In some more paranoid organizations, this can be done because of previous security worries.

junior_bAuthor Commented:
It seems I have to forget VBS and learn JS - in any case, for client side scripting...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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