faqts : Computers : Programming : Languages : JavaScript : Frames

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

12 of 17 people (71%) answered Yes
Recently 5 of 9 people (56%) answered Yes

Entry

How can I bookmark framed pages?

Oct 7th, 2000 14:00
Hal Pawluk,


Just using the menu or ctl/cmd-D to bookmark a framed page won't work. 
All that's bookmarked is the outer frameset page, so when users come back 
to your site, they have to dig through it again to find the information 
they want. When I added frames to my site, I decided to do something 
about the problem.
Start by putting this script into the head of your page (link to a 
Dreaweaver extension available below):
 <SCRIPT>
function frameBooker_hp(){
   var is_4up = parseInt(navigator.appVersion);
   var is_mac = navigator.userAgent.toLowerCase().indexOf("mac")!=-1;
   var is_ie = navigator.userAgent.toLowerCase().indexOf("msie")!=-1;
   var thePage = location.href;
   if (thePage.lastIndexOf('#')!=-1)     //if there, strip anchor
      thePage = thePage.substring(0,thePage.lastIndexOf('#'));
   if (is_ie && is_4up && !is_mac) 
      window.external.AddFavorite(thePage,document.title);
   else if (is_ie || document.images)
      booker_hp =
window.open(thePage,'booker_','menubar,width=325,height=100,left=140,top=
60');
   booker_hp.focus();
   } 
</SCRIPT> 
That will open the framed page in a small new window (Netscape and on the 
Mac) where it can be bookmarked. Now select an image or text with a null 
link in the body of the page and add the call to the frameBooker_hp 
function like this:
    <A href="javascript:void(0)" onClick="frameBooker_hp()">Bookmark this 
page</A>
   <A href="javascript:void(0)"><IMG src="imagename.gif" onclick=
"frameBooker_hp()"></A>
This will work but you see only a portion of the page being framed and 
the user may be confused because there are no instructions on what to do 
next. To solve that problem, insert the following code immediately after 
the <BODY> tag in your page. It will push your content out of sight and 
tell the user what to do to bookmark the page: 
<SCRIPT language="JavaScript" name="frameBooker_hp">
if (window.name=='booker_'){
    var pre_fix = document.images? '<BR>':'';
   document.write(pre_fix + '<P align="center">'
   + 'Please use Ctrl/Cmd-D or the menu now <BR>to bookmark the framed 
page<BR>'
   + 'then <A href="javascript:window.close();">close this window</A></p>
'
   + '<P> </P><P> </P><P> </P><P> </P><P> </P>
');
   }
</SCRIPT>
If you're a Dreamweaver user, you can save yourself some effort by 
downloading my frameBooker extension from the Dreamweaver page http://
www.pawluk.com/public/  (mouse over 'Other Stuff' and click on 
'FrameBooker'). I've tested it with Netscape 3+ and Explorer 4+ on 
Windows and the Mac.