Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

browser sniff in frames

Status
Not open for further replies.

boyfromoz

Technical User
Feb 1, 2001
469
AU
I'm building a website using four frames. Header,top,left and main frames. I have some buttons in the top frame that are load different url's in the main frame.

There is one particular page that I need a browser sniff for. I want the user to press the button, a sniff happens, and then either page "a" or "b" will load in the main frame depending on the user's browser.

I can't find anyway to do this sniff, then direct the new file to load in the main frame. the MMM sniff doesn't give me an option where to load it.

How can I do this?
 
Hello nippi!

Try this:
1) select your link (or button);
2) open Behaviors Window (Window > Behaviors);
3) select Check Browser behavior (Plus Sign + > Check Browser);
4) carefuly fill all fields out in the dialog window;
5) test it. If works not good, reedit behavior again;
6) don't forget to set the value of attribute TARGET of your link to your main frame.

Hope it'll help.

Good Luck!
 
(1) There is no way in check browser behaviour to specify the frame. There is no "target" option.

(2) I can't find where to put it in the code. Everything I've tried, does not work.

If you have used this method succesfully, I'd be interested to know how/where you have specified target = main.

 
Hello nippi!

OK!
If you did everything I suggested to you you should have next script on your page (probably in the HEAD):

function MM_checkBrowser(NSvers,NSpass,NSnoPass,IEvers,IEpass,IEnoPass,OBpass,URL,altURL) { //v4.0
var newURL='', verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr);
if (app.indexOf('Netscape') != -1) {
if (version >= NSvers) {if (NSpass>0) newURL=(NSpass==1)?URL:altURL;}
else {if (NSnoPass>0) newURL=(NSnoPass==1)?URL:altURL;}
} else if (app.indexOf('Microsoft') != -1) {
if (version >= IEvers || verStr.indexOf(IEvers) != -1)
{if (IEpass>0) newURL=(IEpass==1)?URL:altURL;}
else {if (IEnoPass>0) newURL=(IEnoPass==1)?URL:altURL;}
} else if (OBpass>0) newURL=(OBpass==1)?URL:altURL;
if (newURL) { document.location=unescape(newURL); document.MM_returnValue=false; }
}


Do you have it? If yes take a look at the second word "document" from the end. See? where "document.location=unescape(newURL)". You will have to change this word (object) "window" to "top.NAME_OF_YOUR_FRAME" where NAME_OF_YOUR_FRAME is name of your frame (main I guess). It works - I checked.
The full code now look like this:

function MM_checkBrowser(NSvers,NSpass,NSnoPass,IEvers,IEpass,IEnoPass,OBpass,URL,altURL) { //v4.0
var newURL='', verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr);
if (app.indexOf('Netscape') != -1) {
if (version >= NSvers) {if (NSpass>0) newURL=(NSpass==1)?URL:altURL;}
else {if (NSnoPass>0) newURL=(NSnoPass==1)?URL:altURL;}
} else if (app.indexOf('Microsoft') != -1) {
if (version >= IEvers || verStr.indexOf(IEvers) != -1)
{if (IEpass>0) newURL=(IEpass==1)?URL:altURL;}
else {if (IEnoPass>0) newURL=(IEnoPass==1)?URL:altURL;}
} else if (OBpass>0) newURL=(OBpass==1)?URL:altURL;
if (newURL) { top.NAME_OF_YOUR_FRAME.location=unescape(newURL); document.MM_returnValue=false; }
}



If something is wrong say - I'll send you a full code including HTML. And don't forget to do what I suggested above about applying behavior to link!


Good Luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top