Jump to content
xisto Community
Sign in to follow this  
swiideman

Ssi And Javascript Browser Friendly Navigation

Recommended Posts

I'd be willing to 'donate' to anyone who can solve this dilemna.

 

I have two navigations, one that works for IE6+, NS7+, & Firefox and one that doesn't. I found a great redirect script, but I'm not interested in redirecting.

 

I'd rather have the old navigation show up if the browser is not IE6+, NS7+ or Firefox.

 

I'm using SSI on this site, so I'd like to simply have:

 

---------------------------------

 

if navName = Microsoft Internet Explorer & version >= MSIE 6.0 OR navName = Netscape & version >= 5.0

 

THEN display header1.asp [header1.asp has a css-driven navigation - mostly text]

 

ELSE

if navName = Firefox'

THEN display header1.asp

ELSE display header2.asp [header2.asp includes a HEAVY javascript navigation]

 

--------------------------------

 

I'm using IIS, so the Perl script <!--#whatever include=header1.asp --> won't work for me. No Perl please.

 

--------------------------------

 

To keep the file size down, I don't want the older navigation to be loaded UNLESS they have an older browser. Here's the actual syntax I'm using (which isn't working): [some of the code for verNumIE and verNumOt is in an external file]. This script works for redirects, but for not creating includes.

 

PLEASE HELP. B)

 

----------------------------------

 

<script language="JavaScript">

if (navigator.appName == 'Microsoft Internet Explorer') {

verNumIE() ;

} else {

verNumOt() ;

}

 

if ((navName == 'Microsoft Internet Explorer' && brNum >= 'MSIE 6.0') || (navName == 'Netscape' && brNum >= '5.0')) {

document.write('<!--#include virtual="/ssi/header1.asp" -->');

}else {

 

if (navName == 'Firefox') {

document.write('<!--#include virtual="/ssi/header1.asp" -->');

} else {

document.write('<!--#include virtual="/ssi/header2.asp" -->');

}

}

</script>

 

------------------------------------------

Share this post


Link to post
Share on other sites

This is physically impossible. You see, when a webpage is loaded, it is requested from the server. The server then runs the SSIs, etc. and sends the page to the client. On the clients machine, the page is loaded and e.g. javascript is run. You are trying to add SSIs in the Javascript part of the process, but it has already finished processing SSIs. It might be possible to do this with AJAX, but I think the simplest solution would be a cookie based approach. When you figure out whether a browser is compatible or not, set a cookie.

<script>if(compatible)document.cookie="version=new";elsedocument.cookie="version=old";location.href="#"; //Refresh the page</script>
Then in your server-side language, you need to check the cookie. If
a) the cookie does not exist;
Display the javascript to check the compatibility.
:ph34r: the cookie has a value of "new";
Include the new page
c) the cookie has a value of "old";
Include the old page.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.