Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 21-11-2009
Member
 
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?
Reply With Quote
  #2  
Old 21-11-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
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;
Reply With Quote
  #3  
Old 21-11-2009
Member
 
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?
Reply With Quote
  #4  
Old 21-11-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Problem of iframes"
Thread Thread Starter Forum Replies Last Post
Will using iFrames hurts SEO Weeraz Software Development 7 21-02-2012 07:42 AM
How to Implement iframes in a form Shanbaag Software Development 3 23-09-2009 12:52 PM
How to use $_GET in iframes BansiJ Software Development 2 26-08-2009 09:54 PM
Passing variables using iframes Sayam Software Development 3 07-08-2009 12:20 PM
Embed iframes in Flash Chain-SmokeR Technology & Internet 3 13-07-2009 11:59 AM


All times are GMT +5.5. The time now is 05:58 AM.