View Full Version : Frameset Fix
ecnarongi
12-18-2002, 06:26 PM
I have a web site that is broken into frames. when my sites comes up on a search engine only one of the pages from the frameset show up. is there a way that I can redirect or something to get the entire page and not just one of the frames.
I know a simple redirect script on each page (frame) will result in an infinite loop. is there another trick that I can pull while keeping the frameset, so when one of my pages shows up on a search that they searcher doesn't just get the guts of the page and no graphics/ navigation
all help is appreciated.
jalarie
12-18-2002, 07:05 PM
If JavaScript is available.... Unfortunately, many users turn it off.
Have the page check to see whether or not it is within a frameset and redirect to the main frame page with itself as a link:
if (self != top) {
top.location='main.htm?'+self.location;
}
Change the main page to check for extra information after the question (?) mark, use it if it's there, and default to something appropriate otherwise:
par=document.location.search.substring(1);
if (par == '') { par='default.htm'; }
document.write('<frameset rows="85,*">\n');
document.write(' <frame src="top.htm">\n');
document.write(' <frame src="'+par+'">\n');
document.write('<\/frameset>\n');
You can get extra fancy using '<noframes>' and what to do if you don't have JavaScript, but that's the main idea. You can see similar work on my site when you pop out of frames and then want to get back in. The site address is:
http://spruce.flint.umich.edu/~jalarie/
beetle
12-18-2002, 07:58 PM
I've done a similar script to jalarie's using cookies, if you are interested.
ecnarongi
12-18-2002, 08:09 PM
thanks fellas, I will incorp this in my code and see what I get.
ecnarongi
12-18-2002, 10:04 PM
if (self != top) {
top.location='main.htm?'+self.location;
}
don't you mean
if (self == top) {
top.location='main.htm?'+self.location;
}
because I wanted the frame to go back to the main page, thanks again it worked.
Alias
05-07-2003, 10:09 PM
Good idea and best script for frameset redirect ... but ...
in this case visitor can't save my page ...
what to do ?
jalarie
05-08-2003, 12:50 PM
ecnarongi, you are correct. I use the "self != top" on the main entry point of my site, and just grabbed the code without properly noticing that it was the reverse of what I wanted.
Alias, you are correct that a visitor can't generally save a bookmark/favorite to a specific page when s/he's within a frameset. But this method DOES work because it also saves the "query" string and later uses it to get the proper page.
Alias
05-09-2003, 12:53 AM
hello all
jalarie, i didn't mean on bookmarks/add to favorites i mean that you can't SAVE any PAGE with SAVE AS (IE) and SAVE PAGE AS (NS) ...
(in Netscape is possible to save page with SAVE FRAME AS and with right click THIS FRAME > SAVE FRAME AS ... but Netscape visitors are only 10 % of all visitors)
and it is very important ... i want to my visitors can save website content to computer ...
Best Regards
glenngv
05-09-2003, 05:56 AM
you can put a link for each page for IE like:
<a href="javascript:document.execCommand('SaveAs')">Save this page</a>
Alias
05-09-2003, 05:31 PM
thanx glenngv :)
i know for that and i use it ...
but if visitors save page with SAVE AS ... nothing will be saved
and they will look like this :eek: when they try to open saved pages ...
... ;)
regards
note:
document.execCommand('SaveAs') doesn't work in IE 4.0 and 5.0
in IE 5.0 works in single page but not in frameset (if button is in top frame it can't save page from main frame)
Lefteris
05-10-2003, 10:03 AM
Note that if you use a redirection script, even in javascript, most search engines will not link your page.
Alias
05-10-2003, 07:22 PM
i try to solve this problem on this way :
(but i need help form javascript masters)
<script language="Javascript" type="text/javascript">
if (self.location == top.location) {
framer=window.open("FRAMESET.htm","","resizable=1,menubar=1,status=1,scrollbars=0,toolbar=0");
HERE I NEED SOMETHING LIKE > when framer is loaded=framing();
I TRY WITH framer.onload=framing();
BUT IT DOESN'T WORKS - ONLY OPENS FRAMESET PAGE
I TRY ALSO WITH setTimeout('framing()', 10000);
AND IT WORKS
BUT IT DEPENDS ON framer LOADING TIME AND IT IS NOT GOOD SOLUTION
}
function framing(){
framer.main_frame.location.href=self.location;
}
</script>
I WILL APPRECIATE ANY SUGGESTION
regards
beetle
05-10-2003, 09:39 PM
framer.onload = framing();
is incorrect
framer.onload = framing;
is the proper syntax
glenngv
05-12-2003, 10:06 AM
Originally posted by Alias
note:
document.execCommand('SaveAs') doesn't work in IE 4.0 and 5.0
in IE 5.0 works in single page but not in frameset (if button is in top frame it can't save page from main frame)
try:
top.frames['nameOfTargetFrame'].document.execCommand('SaveAs')
Alias
05-12-2003, 04:55 PM
hello glenngv
yes i try every combination with
document.execCommand('SaveAs') in IE 5.0:
top.frame_name.document.execCommand('SaveAs');
parent.frame_name.document.execCommand('SaveAs');
window.frames['frame_name'].document.execCommand('SaveAs');
top.frames['frame_name'].document.execCommand('SaveAs')
document.frame_name.execCommand('SaveAs');
document.getElementById('frame_id').execCommand('SaveAs');
and this are the facts:
ie 4.0 doesn't work - not in single page and not in frameset
ie 5.0 works in single page but doesn't in frameset (in fact it works but it saves BLANK frameset page - not page from main frame)
in ie 5.5 and 6.0 works in both
if somebodyu have solution for IE 5.0 I will be very happy
But this is my BIG problem
when i try (this reside in opener):
if (self.location == top.location) {
frameset_child=window.open("FRAMESET.htm",""," resizable=1,menubar=1,status=1,scrollbars=0,toolba
r=0");
frameset _child.onload=framing;
function framing(){
top.frameset_child.main_frame.location=self.location;
}
it doesn't works
but when i click link (also in opener)
<a href="javascript:framing();">open self location in frameset_child</a>
it works !
i suppose that function frameset _child.onload=framing;
starts before child window is opened
how check if child window is COMPLETELY loaded ?
glenngv
05-13-2003, 04:39 AM
as said in MSDN (http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/constants/saveas.asp), SaveAs works in IE4 and up. I don't know if it's completely true.
try focusing the target frame first...
top.frames['frame_name'].focus();
top.frames['frame_name'].document.execCommand('SaveAs');
as for your other problem, replace this function:
function framing(){
top.frameset_child.main_frame.location=self.location;
}
with:
function framing(){
window.open(self.location,'main_frame');
}
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.