Web Analytics Made Easy -
StatCounter Dynamically resetting a Frame - CodingForum

Announcement

Collapse
No announcement yet.

Dynamically resetting a Frame

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamically resetting a Frame

    Hi,

    I have an HTML frame file. Something like.
    Code:
    <html>    
     <frameset rows="70,*">      
      <frame  src="/somePath/TestServlet?myParam=509" name="code">      
      <frame  src="/somePath/AnotherTestServlet?myParam=737" name="menu">    
     </frameset>
    </html>
    Within the "code" frame, a page is dynamically generated that links to a javascript file I have.. myFile.js

    Within that file, I would like to be able to write a new file to the "menu" frame.

    MyFile.js looks something like...
    Code:
    someFunction()
    {
          var url = "/somePath/AnotherTestServlet?myParam=82347;      
          window.open( url );
    }
    However (obviously), this is incorrect because it opens in a new window, instead of replacing the existing frame named "menu"

    So, my question is "What is the code necessary to make that new url open in an existing frame?".

    Also, this needs to happen WITHOUT user interaction (i.e. pressing a button).

    Thanks,

    Me

  • #2
    Umm, try:
    Code:
    location.href = url;
    instead of:
    Code:
    window.open( url );
    Hope that helps,
    Sadiq.

    Comment


    • #3
      How will that know to open up in the correct frame though?

      I can't write <A> tags around the link because that will require a user click.

      So without <A> tags, I don't know how to send a target="";

      Comment


      • #4
        The link is being called from the other frame. Not the frame that is changing.

        Comment


        • #5
          Oh sorry,

          Then try this:
          Code:
          top.menu.location.href = url;
          I'm pretty sure that'll do it.

          Sadiq.

          Comment


          • #6
            I just tried
            Code:
            parent.frames["menu"].location.href=url;
            I'll try your too.

            Thanks

            Comment


            • #7
              try this too:

              window.open(url, "menu");

              that will work (no js error and the page will still be opened) even if the pages are not in frames
              Glenn
              vBulletin Mods That Rock!

              Comment

              Working...
              X