cross frame scripting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shabbbir
    New Member
    • Apr 2012
    • 7

    cross frame scripting

    i have two frames in a frameset. i want pass variables between them i have write the following code.

    Code:
    <frame set>
    <frame src="forte.html" name="frame1">
    <frame src="http://192.168.1.6/sample.html" name="frame2">
    </frame set>
    in forte.html file
    i wrote the following script
    <script language="javas cript">
    function fun1()
    {
    window.parent.f rame2.form.cont act.value=999;
    }
    </script>
    <body>
    <form name="form" action="">
    <input type="text" name="contact">
    </body>
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    what happened after you wrote this code?

    Comment

    • shabbbir
      New Member
      • Apr 2012
      • 7

      #3
      i'm not able to pass variables between those frames.
      is it possible to access dom objects of url address.please help me.
      thanks

      Comment

      • shabbbir
        New Member
        • Apr 2012
        • 7

        #4
        From FRAME A, I'm trying to access the content of FRAME B, which is loaded in from a different server. Is there a way of doing that? Can I assign everything on the page contained in FRAME B to a variable and then examine the contents of this variable?
        please help me ?

        Comment

        • johny10151981
          Top Contributor
          • Jan 2010
          • 1059

          #5
          try

          Code:
          parent.window.frame_name.variable_name

          Comment

          • shabbbir
            New Member
            • Apr 2012
            • 7

            #6
            yes i have already tried it is not coming.

            2nd frame src is a url another server 192.168.1.4.
            the file is present another system.can i modify that file form text field value.

            Comment

            • johny10151981
              Top Contributor
              • Jan 2010
              • 1059

              #7
              try ifram, i tested with ifram, it works fine

              Comment

              • shabbbir
                New Member
                • Apr 2012
                • 7

                #8
                can u give example for that please

                Comment

                • johny10151981
                  Top Contributor
                  • Jan 2010
                  • 1059

                  #9
                  This code works fine for me
                  index.php
                  Code:
                  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
                     "http://www.w3.org/TR/html4/frameset.dtd">
                  <HTML>
                  <HEAD>
                  <TITLE>A simple frameset document</TITLE>
                  </HEAD>
                  <FRAMESET cols="20%, 80%">
                  
                        <FRAME name='j1' src="johny.htm">
                        <FRAME name='j2' src="johny_2.htm">
                  </FRAMESET>
                  </HTML>
                  johny.htm
                  Code:
                  <INPUT TYPE=BUTTON onclick="alert(parent.window.j2.test_var);" value='haha'>
                  johny_2.htm
                  Code:
                  johny
                  <SCRIPT>
                  var test_var='my name is johny';
                  </SCRIPT>
                  It works fine in chrome

                  Comment

                  • shabbbir
                    New Member
                    • Apr 2012
                    • 7

                    #10
                    that's ok thanks but in mycase 2nd frame src is url like http://192.168.1.6/sample.html.
                    Code:
                    <form name="f1">
                    <input type="text" name="contact"></form>
                    i want assign that text box.
                    javascript function not working for that because 2nd frame src not local.it stored in another computer.so i want access external dom file

                    Comment

                    • johny10151981
                      Top Contributor
                      • Jan 2010
                      • 1059

                      #11
                      I made another test, it works in my machien too

                      johny.htm
                      Code:
                      <INPUT TYPE=BUTTON onclick="alert(parent.window.j2.kaka.value);" value='haha'>
                      johny_2.htm
                      Code:
                      johny
                      <SCRIPT>
                      var test_var='my name is johny';
                      </SCRIPT>
                      
                      <input type='text' value='test' id='kaka'>
                      make it work for you too

                      Comment

                      • johny10151981
                        Top Contributor
                        • Jan 2010
                        • 1059

                        #12
                        it was not suppose to be a problem. cause browser don't recall remote or local. for browser all are remote

                        Comment

                        • shabbbir
                          New Member
                          • Apr 2012
                          • 7

                          #13
                          thank you i will try that

                          Comment

                          Working...