[RESOLVED] Javascript: finding parent frame
Helo!
My home page has frames.
I don't want pages to be opened without being in the main frame (other frames are links and footer).
First, how to find whether the page is in a frame?
Second, how to force INDEX.HTML to show it (without changing it to ASP)?
Re: Javascript: finding parent frame
This is your problem:
Quote:
Originally Posted by Lemon Lime
My home page has frames.
For everyone's sake (but mostly yours), ditch the frames. They are so 90's ;)
Besides, no-one will ever find you on a search engine if you have frames. And it makes life unbearable complicated, as you're already finding out.
Re: Javascript: finding parent frame
GGGGGRRRRR.... :mad:
I started working on it with frames, so I guess I can't just get rid of them.
As long as I'm the ONLY webmaster, it might be a bit impossible mission... :rolleyes:
Well, people are finding pages in my site, (even with GOOOOOOGLE!!!) but can't navigate out, to see other links.
I found this http://adamv.com/dev/javascript/querystring.
After figuring out I wrote this on my page:
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<html>
<script src="querystring.js"></script>
<head>
<meta http-equiv="Content-Language" content="he">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
<title>index.html</title>
<base target="main">
</head>
<frameset cols="*,165" framespacing="0" frameborder=0 >
<frameset rows="*,95" frameborder=0>
<frame name="main" scrolling="auto" noresize frameborder=0 target="main" src="main.htm">
<frame name=footer src=footer.htm frameborder=0 >
</frameset >
<frame name="links" src="links.htm" scrolling="auto" frameborder=0 target="main"></frameset>
<script type='text/javascript'>
var qs = new Querystring();
var file1 = qs.get('redir','main.htm');
document.getElementById("main").src = file1
</script>
</html>
When writing
Code:
index.html?redir=123.html
I get nothing!
What da?!
Re: Javascript: finding parent frame
To detect if you're in frames or not,
if(top.location.href == self.location.href)
This means that you are NOT in frames. If this evaluates to true, set top.location.href to your frame page.
I don't understand what you want in your second post though, can you explain?
Re: Javascript: finding parent frame
10X!
I want to redirect all files to "/index.html" BUT to still be in the same page.
i.e: if i open http://.....gallery.html so it will open index.html, and gallery.html will be showen in the "main" frame.
Re: Javascript: finding parent frame
Use
top.frames['mainframe'].document.location.href = file1
Instead of
document.getElementById("main").src = file1
Re: Javascript: finding parent frame
It does'nt work.
this is my new file:
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="he">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
<title>INDEX</title><base target="main">
<script src="querystring.js" type="text/javascript"></script>
<script type='text/javascript'>
function reframe() {
var qs = new Querystring();
var file = qs.get('redir','main.htm');
top.frames['main'].document.location.href = file;}
</script>
</head>
<frameset rows="*,95">
<frame name='main' id='main' scrolling="auto" noresize frameborder=0 src="main.htm">
<frame name=footer src=footer.htm frameborder=0 >
</frameset>
</html>
and still...
Re: Javascript: finding parent frame
after getting the file variable, try alert(file);
What do you get?
Re: Javascript: finding parent frame
Re: Javascript: finding parent frame
Code:
window.onload=reframe;
and it's done!
now, about the first one....
Code:
if(top.location.href == self.location.href){
document.redirect("index.html?redir=" +document.href);}
is wrong...
Re: Javascript: finding parent frame
if(top.location.href == self.location.href){
top.location.href = "index.html?redir=" + document.href);}
Re: Javascript: finding parent frame
10X!!!!!!!
Code:
if(top.location.href == self.location.href){
top.location.href = "index.html?redir=" +top.location.href;
document.refresh}
Re: Javascript: finding parent frame
You're welcome, add 'Resolved' to the thread title now. :)
Re: [RESOLVED] Javascript: finding parent frame
I know I can be a real pain in the A$$ but it's not so good..
Is it possible not to show the full URI (of the second page) on the address?
It's like this :
file:///D:/container/index.html?redir=file:///D:/container/copy%20of%20main.htm
And it's :sick: