+ Reply to Thread
Results 1 to 7 of 7

Thread: JavaScript Frames

  1. #1
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    JavaScript Frames

    I can't figure out how to access a frame from inside the frame page. In my real script, I am trying to change the title of the window to that of a certain frame. I tried self.framename like I was told, but no luck, can anybody with experience help?
    HTML Code:
    html>
    <head>
    <script type="text/javascript">
    if ( document.title =  ... .title  ) alert("True");
    </script>
    </head>
    <frameset cols="25%,50%,25%">
      <frame name="framea" src="frame_a.htm">
      <frame name="frameb" src="frame_b.htm">
      <frame name="framec" src="frame_c.htm">
    
    <noframes>
    <body>Your browser does not handle frames!</body>
    </noframes>
    
    </frameset>
    
    </html>
    This is a modified version from this TryIt Editor from w3schools, I find it much easier.

    Edit:
    Thank you all who tried to help, the answer was self.framename.document.title, but it did not work is because the file loaded was from a remote server, so access was denied to JavaScript. Took me a while. A more accurate version of my script is:
    HTML Code:
    html>
    <head>
    <script type="text/javascript">
    if ( document.title =  self.framea.document.title  ) alert("True");
    </script>
    </head>
    <frameset cols="25%,50%,25%">
      <frame name="framea" src="http://yahoo.com">
      <frame name="frameb" src="frame_b.htm">
      <frame name="framec" src="frame_c.htm">
    
    <noframes>
    <body>Your browser does not handle frames!</body>
    </noframes>
    
    </frameset>
    
    </html>
    This got me an access denied error message. If anybody knows a way to do this, either with JavaScript or PHP, please tell me. Smart people don't use frames :P
    Last edited by Twinkie; 12-21-2008 at 10:40 PM.

  2. #2
    quantum1's Avatar
    quantum1 is offline x10Hosting Member quantum1 is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    near Nashville, TN
    Posts
    68

    Re: JavaScript Frames

    Are you trying to change the title depending on what frame the cursor is in? That is, if the cursor is in frame a you want the title of the browser window to be the title of frame a?
    Two rules of development:
    1) Computers work for people; People do not work for computers
    2) Maintainability is all that matters.

  3. #3
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    Re: JavaScript Frames

    Noo, I am trying to change the name of the main window based on the title of frame a. I don't believe this is possible because framea is loaded from a remote server (Yahoo!).

  4. #4
    quantum1's Avatar
    quantum1 is offline x10Hosting Member quantum1 is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    near Nashville, TN
    Posts
    68

    Re: JavaScript Frames

    If you are or want to use Firefox you can download the Firebug add-on and it will allow you to poke around the HTML DOM environment and mess with Javascript entities and so forth. That might help you figure out this and other stuff.
    Two rules of development:
    1) Computers work for people; People do not work for computers
    2) Maintainability is all that matters.

  5. #5
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    Re: JavaScript Frames

    Thanks, I will try that.

  6. #6
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: JavaScript Frames

    Firebug isn't the best tool to use with Frames, only because not all of the DOM is documented in the tree and the ones that are aren't in alphabetical order.

    Truth is, I'm not sure that you can do this. The problem wouldn't be because the page is on a remote server because the HTML of the page is readable (can be accessed) by any computer. The only thing that matters is the parent window of the frameset. The problem is that I don't think you can access the frames that way.

    Does self.framename.document.title work? Generally, you'd want to use top.framename.document.title from within one of the frames themselves... I don't think you can do this in the html file that controls the frameset.
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


  7. #7
    t2t2t's Avatar
    t2t2t is offline x10 Elder t2t2t is an unknown quantity at this point
    Join Date
    Sep 2006
    Location
    Europe, Estonia
    Posts
    690

    Re: JavaScript Frames

    Quote Originally Posted by Twinkie View Post
    I don't believe this is possible because framea is loaded from a remote server (Yahoo!).
    Yep, you can't access content in a frame from remote server using javascript. It's because of security (Eg. sending data in cookies to another site)
    This post has been marked spam 52 times.


+ Reply to Thread

Similar Threads

  1. Making a site JavaScript dependent - pros/cons?
    By Tarzan in forum Programming Help
    Replies: 8
    Last Post: 07-11-2008, 10:08 AM
  2. drop down menus with JavaScript disabled?
    By sifaka in forum Free Hosting
    Replies: 1
    Last Post: 05-15-2008, 10:46 AM
  3. javascript and external javascript files problem
    By delon in forum Programming Help
    Replies: 6
    Last Post: 04-27-2008, 12:41 AM
  4. XML and Javascript
    By cuteboytm in forum Graphics & Webdesign
    Replies: 1
    Last Post: 09-21-2007, 10:00 AM
  5. Do frames cause a problem?
    By Shoelace in forum Free Hosting
    Replies: 6
    Last Post: 02-14-2006, 09:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers