Forum Moderators: open

Message Too Old, No Replies

having javascript find out the frame situation and changing it

         

phoenix_fly

3:00 pm on Jun 6, 2005 (gmt 0)

10+ Year Member



Hello my code friends,

In this site I am using this zero-height frame technique to routines like drop-down-menu updating without having to refresh the main frame. But now it hit me that maybe when I air up the site, search engines may present the links to the internal pages, and so my hidden frame wonīt be present!

I thought maybe having javascript to check if the zero-height frame is present, everytime that I may need it. If it isn't, having javascript to shift the content of the frameless window into a B frame, having A as a zero-height frame...

You guys know if this is possible?

In fact, I could have this pivot-role made by a pop-up window. But the point is that the frame technique is good to hide the parameters we pass through the non-hidden frame, while the browser's adress bar shows up only our siteīs domain, you know...

I wait for your help then,

Thanks a lot

phoenix_fly

RonPK

6:05 pm on Jun 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi phoenix_fly,

In the pages to be framed, add this piece of script:

if (top.frames.length==0) { 
document.location= "index.html?thispage.html";
}

In index.html (presuming that's the file that contains your frameset), have javascript write the frameset:


var d = document;
if (self.parent.frames.length!= 0)
self.parent.location = d.location;
a = d.location.href;
b = a.indexOf('?');
if (b == -1) frUrl = 'home.html'; // default content page
else frUrl = a.substring(b+1, a.length);
d.writeln('<frameset rows="0,*">');
d.writeln(' <frame src="top.html" name="topframe">');
d.writeln(' <frame src="', frUrl ,'" name="mainframe">');
d.writeln('</frameset>');

phoenix_fly

11:33 pm on Jun 8, 2005 (gmt 0)

10+ Year Member



Hey RonPK

Thanks for the reply.

My situation is a little bit more tricky: I almost donīt have html pages, as this site is heavily dinamic. So the current non-frame page (wich I have to make a frame page) can be any script.cgi with many parameters sent (through GET only, though! Thank god.)

Is there a way to implement this using the code you sent me? Or it already does that? Sorry Iīm not deeply familiar with these properties you used.

Thanks a lot

phoenix_fly

RonPK

7:33 am on Jun 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sure, try using this in the pages you want to stick into the frameset:

if (top.frames.length == 0) {  
document.location = "index.html?" + document.location;
}

phoenix_fly

8:57 pm on Jun 10, 2005 (gmt 0)

10+ Year Member



Hey Ron,

Ok! Thanks a lot my friend!

See ya around!