Results 1 to 4 of 4

Thread: Problem of iframes

  1. #1
    Join Date
    Jul 2009
    Posts
    122

    Problem of iframes

    I built a website in html/css with a fixed page with menus and stuff, and an iframe to center to view the different pages.

    Problem: I see the statistics of entries on my site are almost 20% of pages that must contain the iframe, visitors are thus on a page without any link and it's annoying!

    You know a way to detect if someone arrives on a page other than the home page that automatically redirects to the homepage of the site. The trick is that when it reaches the page through the site, I fear that it makes an infinite loop of redirection that nobody can visit my site at once!

    Someone an idea?

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Problem of iframes

    Yes, with a bit of javascript.
    HTML Code:
    // If the window frame has no parent: 
    if (! window.parent) 
    // Then redirect to the page with full frame: 
    window.location = 'index.htm?' + window.location;
    In full-page index.htm
    HTML Code:
    <iframe name="myframe"> </ iframe>
    Then the javascript:
    HTML Code:
    // Get the url passed as parameter 
    var url_frame = window.location.search.substr (1); 
    // Url if valid, redirect the frame to this url 
    if (url_frame) window.myframe.location = url_frame;

  3. #3
    Join Date
    Jul 2009
    Posts
    122

    Re: Problem of iframes

    I can not put in place. Maybe I did not understand your code. First part (a file placed in scripts.js), we check if there is no parent page, whether it redirects to the index file of the site, so far ok. Second part, the declaration of the frame in the index file, no problem. And the last part I do not understand and I do not see it or place. Can you enlighten me?

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Problem of iframes

    The last part should be placed after the declaration of the frame in a javascript tag. Line 2: gets the URL of the page, extracts the parameters, and including everything that is found after? Line 4: uses all that is setting in as the URL of the frame to display. If no parameter is passed, do not alter the contents of the frame, allowing you to set a default content loading index.htm.

Similar Threads

  1. Will using iFrames hurts SEO
    By Weeraz in forum Software Development
    Replies: 7
    Last Post: 21-02-2012, 07:42 AM
  2. How to Implement iframes in a form
    By Shanbaag in forum Software Development
    Replies: 3
    Last Post: 23-09-2009, 12:52 PM
  3. How to use $_GET in iframes
    By BansiJ in forum Software Development
    Replies: 2
    Last Post: 26-08-2009, 09:54 PM
  4. Passing variables using iframes
    By Sayam in forum Software Development
    Replies: 3
    Last Post: 07-08-2009, 12:20 PM
  5. Embed iframes in Flash
    By Chain-SmokeR in forum Technology & Internet
    Replies: 3
    Last Post: 13-07-2009, 11:59 AM

Tags for this Thread

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
  •  
Page generated in 1,711,633,645.55030 seconds with 17 queries