Click to See Complete Forum and Search --> : passing css to javascript


ranosb
07-13-2005, 08:17 PM
how can I pass the number 137 value to a javascript using css? Is this possible? The java will only take a number value at 137 position. This is for loading different style sheets for each screen resolution, the textboxwidth must change... What different varations I have tried doesnt pass anything...

layout-grid-line is the top to bottom, I need horizontal spacing.

Example;

.textboxwidth {
137
}



Javascript menu snip:

menu[0] = new Array();
menu[0][0] = new Menu(false, '', 3, 0, 20, '#CCFFFF', '#ffffff', '',

'itemText2');
menu[0][1] = new Item( 'Getting Around', '#', '', 137, 3, 1);


like so:

menu[0][1] = new Item( 'Getting Around', '#', '', 'textboxwidth', 3, 1);

drhowarddrfine
07-13-2005, 10:17 PM
You cannot pass a number using CSS. It is not a programming language. Nor can you enter a value like you have shown.

Kravvitz
07-13-2005, 10:51 PM
ranosb, what are you trying to do?

Che
07-13-2005, 11:26 PM
would loading a different css based on screen resolution help?


<SCRIPT language="JavaScript">
<!--
if ((screen.width>=1024) && (screen.height>=768))
{
<!-- load high res css -->
document.write('<link rel="stylesheet" type="text/css" href="highres.css" title="style" />');
}
else
{
<!-- load low res css -->
document.write('<link rel="stylesheet" type="text/css" href="lowres.css" title="style" />');
}
//-->
</SCRIPT>

felgall
07-14-2005, 06:12 PM
What about someone with a 1024x768 or higher screen who has their browser displaying at below full screen size. Wouldn't it be bettwe to test the available size in the actual browser window rather than the screen size?

Che
07-14-2005, 08:14 PM
Sure. I'm not sure what the requirements are. So i gave it a shot.

bathurst_guy
07-14-2005, 08:40 PM
You could change your code so that the menu itself has a class or id then set this width colours and all other styling properties using the CSS.
Maybe:menu[0] = new Array();
menu[0][0] = new Menu(false, '', 3, 0, 20, 'textboxdiv','itemText2');
menu[0][1] = new Item( 'Getting Around', '#', '', 3, 1);
...
.textboxdiv{
}?

ranosb
07-14-2005, 09:49 PM
Yes, couldnt pass the variable with css, so Im using this...

else if (screen.width == 800) {
var menu0_1 = 110; var menu0_2 = 105;
var menu0_3 = 80; var menu0_4 = 110;
var menu0_5 = 110;

document.write doesnt work with Firefox nor does this; Everything on my website works with IE, but everybody says IE is no good!

else if (screen.width == 800) {
var ss = document.getElementById("s1024"); ss.disabled = true;
var ss = document.getElementById("s1280"); ss.disabled = true;

}

bathurst_guy
07-14-2005, 10:02 PM
document.write does work with firefox

ranosb
07-15-2005, 07:45 PM
It does? So all my doc.write scripts that havent been working when I run FireFox is caused its not setup right?
Is that what your telling me?