Javascript and Frames

Discussion in 'JavaScript' started by tanoanian, Aug 7, 2006.

  1. #1
    Hello,

    I have a page made up of Frame A and Frame B. Frame A is the page with the javascript and I need the script to execute on the contents of Frame B.

    It is a fairly simple script (not mine though). Is there an easy way to accomplish this?

    Thanks!
     
    tanoanian, Aug 7, 2006 IP
  2. Nafai

    Nafai Peon

    Messages:
    105
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I know you can use window.parent to access the main part of the page outside the current frame. I don't know if window.parent.frame2 would access the other frame but it might... I don't think I've ever tried actually. I don't like frames very much so only a couple of my sites even have them hehe =)
     
    Nafai, Aug 7, 2006 IP
  3. tanoanian

    tanoanian Active Member

    Messages:
    207
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Hi,

    Thanks for the reply. Where in the script would I add that? Here is the code I need to modify:

    
    <script type="text/javascript" language="JavaScript">
    function FillForm() {
    var FormName = "MyForm";
    var questionlocation = location.href.indexOf('?');
    if(questionlocation < 0) { return; }
    var q = location.href.substr(questionlocation + 1);
    var list = q.split('&');
    for(var i = 0; i < list.length; i++) {
       var kv = list[i].split('=');
       if(! eval('document.'+FormName+'.'+kv[0])) { continue; }
       kv[1] = unescape(kv[1]);
       if(kv[1].indexOf('"') > -1) {
          var re = /"/g;
          kv[1] = kv[1].replace(re,'\\"');
          }
       eval('document.'+FormName+'.'+kv[0]+'.value="'+kv[1]+'"');
       }
    }
    FillForm();
    //-->
    </script>
    
    Code (markup):
    Thanks in advance!
     
    tanoanian, Aug 8, 2006 IP