basis
11-06-2003, 08:18 AM
Hi All!
I am a novice at JavaScript developing. I develop simple web site. The site is hosted on a server where server-side scripts are disabled. I needed to implement navigation menu on the site. I didn’t want to duplicate menu code in all HTML file so I putted menu code in separate frame. Everything worked well but when a user found one of the site pages by search mashine the page was opened without menu frame. So I added to all HTML file following body OnLoad Java Script handler.
function ShowMenu()
{
var sBody = "<frameset rows='50,*' Border = 0>" +
"<frame src=menu.htm ' name='frmMenu' noResize = 'true' scrolling = 'no' >" +
"<frame src=" +
self.location.href +
" name='frmContent'>" +
"</frameset>";
return sBody;
}
// Body OnLoad handler
function CheckMenu()
{
if (!window.parent.frames.length)
{
self.location.href = "java script:ShowMenu()";
}
}
Now script loads menu if anybody tries to open page without frames. But error “The page cannot be displayed” appears if I try to reload (F5) page in IE 6.0. IE address bar contains “java script:ShowMenu()” after that. How can I solve the problem? Maybe is there a solution to add menu without duplication code and without frames?
I am a novice at JavaScript developing. I develop simple web site. The site is hosted on a server where server-side scripts are disabled. I needed to implement navigation menu on the site. I didn’t want to duplicate menu code in all HTML file so I putted menu code in separate frame. Everything worked well but when a user found one of the site pages by search mashine the page was opened without menu frame. So I added to all HTML file following body OnLoad Java Script handler.
function ShowMenu()
{
var sBody = "<frameset rows='50,*' Border = 0>" +
"<frame src=menu.htm ' name='frmMenu' noResize = 'true' scrolling = 'no' >" +
"<frame src=" +
self.location.href +
" name='frmContent'>" +
"</frameset>";
return sBody;
}
// Body OnLoad handler
function CheckMenu()
{
if (!window.parent.frames.length)
{
self.location.href = "java script:ShowMenu()";
}
}
Now script loads menu if anybody tries to open page without frames. But error “The page cannot be displayed” appears if I try to reload (F5) page in IE 6.0. IE address bar contains “java script:ShowMenu()” after that. How can I solve the problem? Maybe is there a solution to add menu without duplication code and without frames?