SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Best way to auto-load frameset from frame

    Whats the best way to load the entire frameset when someone requests one of the pages that should only come up in the frame?
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel

  2. #2
    SitePoint Member
    Join Date
    Jan 2003
    Location
    Bristol, UK
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Force frameset

    I think this is what you want - put it in the head section prior to the <html> tag (index.html is your framest page)

    <script>

    if (parent.location.href == self.location.href){
    window.location.href = 'index.html'
    }

    </script>
    Scripting makes my brain hurt

  3. #3
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool bananas - I've seen much more complex scripts to do the same thing - I was pretty sure they were redundant as proven here. Cheers.
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel

  4. #4
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    More Complex scripts......

    More complex scritps for frames allows the frames to be built around the page asked for, rather than go to the index page.

    try this;
    Code:
    <SCRIPT LANGUAGE="JavaScript">
    
    <!--
    if (top.location !=self.location) {
    top.location.replace(self.location)}
    
    var ar0 = "banner.html";
    var ar1 = "menu.html";
    var ar2 = "main.html";
    
    var str = location.search;
    var pos = str.indexOf("&");
    if (pos != -1) {
      var num = str.substring(pos + 1, str.length);
      window["ar" + num] = str.substring(1, pos);
    }
    
    // -->
    </SCRIPT>
    </HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    
    document.write(
    '<FRAMESET rows="150,*" border="0" >',
      '<FRAME SRC="', ar0, '" NAME="menu2" scrolling="no">',
      '<FRAMESET cols="150, *" border="0">',
        '<FRAME SRC="', ar1, '" NAME="banner" >',
        '<FRAME SRC="', ar2, '" NAME="main">',
      '</FRAMESET>',
    '</FRAMESET>'
    );
    
    // -->
    </SCRIPT>
    then put this into each html document,
    Code:
    if (top.location.href.indexOf("index.html") == -1)
      top.location.href = "index.html?didjtnc.html&2";
    the above js would be in the html document named didjtnc.html

    When you go to this page, it loads your index page and puts didjtnc.html into the 2nd frame, where 0 is banner, 1 is menu, and 2 is mainpage

    hope this helps
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  5. #5
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Get out of others frames....

    the top bit of that program
    Code:
    if (top.location !=self.location) {
    top.location.replace(self.location)}
    gets your site out of other peoples frames if they link to your site within a frame
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if


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
  •