SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: URL in frameset

  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    URL in frameset

    hello friends,

    i want to pass the URL through addressbar in frameset based pages.......
    if i bookmark that page .......... the exact page doesnt open ....... please help me how to pass a url in the addressbar........

    thanks in advance....

  2. #2
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In other words, if a user visits the page directly, you want to redirect to your frameset page and have that page load into a frame on the frameset page? Try this.


    In the first page:
    Code:
    if (window == top) window.location.href = "frameset.html?" + encodeURIComponent(window.location.href);
    In the frameset page:
    Code:
    myFrame.src = decodeURIComponent(document.search);

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is my frameset...........
    show_frame.html
    <frameset rows="30&#37;,70%">
    <frame src="head.html">

  4. #4
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The frame you want to load the page into must have a name or id attribute (for instance, the "myFrame" in the above example) for this to work. Also, your scripts should be constructed in such a way that they only get triggered after the respective pages are completely loaded, e.g., by placing the example code in functions and calling those functions from the window or document body's onload handler.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is my frameset.............. where i have to give ur code..........
    show_frame.html
    <frameset rows="30&#37;,70%">
    <frame src="head.html">
    <frameset cols="30%,70%">
    <frame src="navigation.html">
    <frame src="content.html">
    </frameset>
    </frameset>

    if i bookmark the page it always store top of the url not content.html............
    what i have to do.....

  6. #6
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the thing. I don't make it a habit to spoon feed complete scripts in response to questions here, but rather toss out general ideas and let the pupil work out the specific implementation on his own. However, I'll go ahead and write out a working solution and test it just to make sure I'm not leading you astray. This will take a little time, so check back in a bit.

  7. #7
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As fate would have it, there were indeed issues with the code fragments I posted above. First, there is no such property as document.search. The property I was looking for is window.location.search. Second, window.location.search contains the question mark as well as the query string, so you have to take the extra step of removing the question mark in order to get the actual query string. The following works in both Firefox 3 RC 2 and Internet Explorer 7.

    hello.html:

    Code:
    <html>
     <head>
      <script type="text/javascript">
       function redirectToFramesPage() {
        if (window == top) window.location.href = "frames.html?" + encodeURIComponent(window.location.href);
       }
       
       window.onload = redirectToFramesPage;
      </script>
     </head>
     <body>
      <h1>Hello, World!</h1>
     </body>
    </html>
    frames.html:

    Code:
    <html>
     <head>
      <script type="text/javascript">
       function loadPageIntoFrame() {
        document.getElementById('myFrame').src = decodeURIComponent(window.location.search.substr(1));
       }
       
       window.onload = loadPageIntoFrame;
      </script>
     </head>
     <frameset rows="20&#37;,80%">
      <frame src="" />
      <frameset cols="20%,80%">
       <frame src="" />
       <frame id="myFrame" src="" />
      </frameset>
     </frameset>
    </html>

  8. #8
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Than q very much friend it s working............
    i am very new to javascript and html thats why...........


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •