-
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?
-
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;
-
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?
-
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.
Page generated in 1,714,280,663.13468 seconds with 11 queries