...

View Full Version : I need a platform-check!



Xoom
06-12-2003, 12:21 AM
Hi, I need help again!

I need to make my site viewable for both PC and Macintosh. For PC the "HV Menu" works very good but it screws up on a Mac. So I've configured "Top Navigational Bar 3 v3.4.1.1b" to work on a Mac.

Both of the menus use SCRIPT REL/SRC-links to external js-files implemented in the HTML-code of the site (that's 1standard I guess). So what I need is a platform-check in the HTML-code that decides wich menu that will show!

Down below I attach the scripts from each menu.

-----------------------------------------
Top Navigational Bar 3 v3.4.1.1b:

In HEAD:
<link rel="stylesheet" href="xtras/styles.css" type="text/css">
<script language="javascript" src="js/sniffer.js">

//Top Navigational Bar III v3.4.1.1b (By BrotherCake @ cake@brothercake.net)
//Permission granted/modified by Dynamicdrive.com to include script in archive
//For this and 100's more DHTML scripts, visit http://www.dynamicdrive.com/
//This notice MUST stay intact for legal use

</script>
<script language="javascript1.2" src="js/custom.js"></script>
<script language="javascript1.2" src="js/style.js"></script>

In BODY:
<script language="javascript1.2" src="js/menu.js"></script>
-----------------------------------------

-----------------------------------------
HV Menu:

In BODY:
<script type="text/javascript">
function Go(){return}
</script>
<script type="text/javascript" src="js/exmplmenu_var.js"></script>
<script type="text/javascript" src="js/menu_com.js"></script>
<noscript>Your browser does not support script</noscript>
-----------------------------------------


So, all I really need is a way to make the browser choose between wich menu it will show (i.e which code it will show)!

Please can anybody help me?

/Xoom

ahosang
06-12-2003, 10:12 AM
<script>
if (navigator.userAgent.toLowercase().indexOf("mac")!=-1) {
//show mac menu here
} else {
//show PC menu here
}

Xoom
06-12-2003, 11:15 AM
Well that's a script which I've been trying to use but I have encountered a problem.

what I've done is:

<script>
if (navigator.userAgent.toLowercase().indexOf("mac")!=-1) {
<script language="javascript" src="js/sniffer.js">

//Top Navigational Bar III v3.4.1.1b (By BrotherCake @ cake@brothercake.net)
//Permission granted/modified by Dynamicdrive.com to include script in archive
//For this and 100's more DHTML scripts, visit http://www.dynamicdrive.com/
//This notice MUST stay intact for legal use

</script>
<script language="javascript1.2" src="js/custom.js"></script>
<script language="javascript1.2" src="js/style.js"></script>
} else {
<script type="text/javascript">
function Go(){return}
</script>
<script type="text/javascript" src="js/exmplmenu_var.js"></script>
<script type="text/javascript" src="js/menu_com.js"></script>
<noscript>Your browser does not support script</noscript>
}
</script>

Cause I can't use script-tags inside a script tag? I've tried using document.write-method too but without success!

Please, what am I doing wrong?

ahosang
06-12-2003, 01:41 PM
When using conditional scripts, document.write out any <script> tags inside the first. BUT, you must break up the <script> and </script> tags:
document.write("<"+"script src='js/sniffer.js'><"+"/script>");
for example

Xoom
06-12-2003, 01:44 PM
Oh I see! Thanks!!

Xoom
06-12-2003, 05:17 PM
Just wanted to report that your platform-check-script didn't work. It should look like this:

// If the platform is Macintosh, use the Macintosh style sheet.
if (navigator.platform.indexOf('Mac') != -1) {
document.write('<link rel="stylesheet" href="/macstyles.css">');
// Otherwise, use the Windows style sheet.
} else{
document.write('<link rel="stylesheet" href="/winstyles.css">');
}

Just if someone else reads this thread and doesn't make it work.

Peace out! And thanks again for all the help!

brothercake
06-12-2003, 05:32 PM
Can't help but ask .. why not just use topnavIII for all platforms? make life much easier ..

Xoom
06-12-2003, 05:55 PM
Well, for starters Top Nav III is much slower. And I haven't been able to configure Top Nav III in the same way as the HV Menu.

What I thought was perfect in the HV Menu was the TargetLoc-variable that made it possible to lock the menu to a desired tablecell with a DIV-tag (ID=MenuPos) inside. In that way the menu always kept in place, even if you resized the window and such. And it didn't followed out the side of the window.

Am I wrong?..

brothercake
06-12-2003, 08:11 PM
The speed comment is fair - topnav III is slower loading than HV, but it's far more configurable, or at least in it's most recent incarnation it is - http://www.brothercake.com/dropdown/

Xoom
06-12-2003, 08:37 PM
But I can't lock topnavIII into a cell? I must either position it with a static pixelvalue from the left or center it on the page?

brothercake
06-12-2003, 08:49 PM
yeah you can - http://www.brothercake.com/dropdown/topnavIII/relative.html

Xoom
06-12-2003, 09:21 PM
oh ok! let me check that out! sounds great! thnx

Xoom
06-12-2003, 10:10 PM
Oh, this works just fine now! Thank you! But still, I can't get arrow-images on topnavIII right?

ahosang
06-13-2003, 01:51 PM
Just to say, I think mine might have worked but there's a typo. Should be:
toLowerCase() rather than toLowercase()

But yes, as you've discovered, navigator.platform is also good for the data needed



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum