473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

place a javascript menu inside a cell of a table.

Hi,

I´m trying to place a javascript navigation menu inside a cell of
a table in my page, the problem is that the constructor of the menu
object has parameters for menu positioning and size and when the
window is rezised the menu stands at the same position and with the
same size.

My question is: is there a way to modify those parameters
dinamically to match window size, and how is that made, or is there
another way to include that menu using a table for page layout.

Thanks.
Jul 23 '05 #1
4 2415
Dacian wrote:
Hi,

I´m trying to place a javascript navigation menu inside a cell of a table in my page, the problem is that the constructor of the menu
object has parameters for menu positioning and size and when the
window is rezised the menu stands at the same position and with the
same size.

My question is: is there a way to modify those parameters
dinamically to match window size, and how is that made, or is there
another way to include that menu using a table for page layout.

Thanks.


You've asked a rather detailed question about a "javascript navigation
menu" which has "parameters". What sort of answer could anyone provide
with that level of detail?

Using the window's onresize handler might be of help. Got a link to
that script, or an example?

Jul 23 '05 #2

This is the function wich is called for displaying the menu

function init()
{

menus[0] = new menu(20, "horizontal", 260, 20, 0, -2,
"img:images/background1.jpg", "img:images/background2.jpg",
"Arial,Helvetica", 9, "bold",
"bold", "white", "white", 0, "white", 2,
"rollover:images/tri-down1.gif:images/tri-down2.gif", false, false,
true, false, 0, true, 4, 4, "gray");
menus[0].addItem("menu.html", "_blank", 100, "center", "Item 1", 0);
menus[0].addItem("#", "", 100, "center", "Item 2", 1);
menus[0].addItem("#", "", 100, "center", "Item 3", 2);
menus[0].addItem("#", "", 100, "center", "Item 4", 0);
menus[0].addItem("#", "", 100, "center", "Item 5", 0);

}

-The first parameter controls the size of the menu (height)

-The third parameter controls the horizontal coordinate of where the
menu is to
be displayed.

-The fourth parameter controls the vertical coordinate of where the
menu is to be
displayed.
-The third parameter in addItem function controls the size of each menu
item.

What I want is to set all this parameters accordingly to the size of
the window,
so the menu always shows up and fits the cell of the table used for
layout of the page.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3
Gerardo Ramírez wrote:
This is the function wich is called for displaying the menu [...] What I want is to set all this parameters accordingly to the size of
the window,
so the menu always shows up and fits the cell of the table used for
layout of the page.


If the menu is inside a table cell, then don't you want it to
fit the cell, not the window?

Make the size parameters into variables that are passed to the
menu function. Then call the menu from another function that
knows or gets the size of the table cell.

Here is some play code that gets the current size of an element,
then makes another element the same size. It uses divs, but the
theory should be the same.

It works in Firefox (getComputedStyle) and IE (currentStyle).
Note that it separates the units that are returned as the thing
I wrote it for wanted to modify the size, so the units had to be
preserved. I've left the code in but you could safely remove it
if all you are doing is copying the returned size to the new
element.

All the "msg" lines can be removed, they're just for demo and
debug to let you know what's going on.

Firefox always reports px, but IE reports whatever was used to
set the height & width = em, px, etc.

It's lightly commented, come back if you need more help.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title> Resize element </title>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">

<style type="text/css">
..div0 {border: 1px solid red; width: 10em; height: 15em;}
..div1 {border: 1px solid blue;}
</style>

<script type="text/javascript">
function sameSize(a,b){
var msg = '';
b = document.getElementById(b);

// Zilla stuff
if (window.getComputedStyle) {
var h = document.defaultView.getComputedStyle(a,
'').getPropertyValue('height');
var w = document.defaultView.getComputedStyle(a,
'').getPropertyValue('width');
msg += '\ngetComputedStyle (h,w): ' + h + ', ' + w;

// IE stuff
} else if (a.currentStyle) {
var h = eval('a.currentStyle.height');
var w = eval('a.currentStyle.width');
msg += '\ncurrentStyle (h,w): ' + h + ', ' + w;
}

// Split off numbers and units
hu = h.replace(/[\d|.]/g,'');
h = h.replace(/[^\d|.]/g,'');
wu = w.replace(/[\d|.]/g,'');
w = w.replace(/[^\d|.]/g,'');

// Apply to the target element
if (b.style) {
msg += '\n\nSetting ' + b.id + ' to (h,w):'
+ h + hu + ', ' + w + wu;
b.style.height = h + hu;
b.style.width = w + wu;
}

alert(msg)
}
</script>
</head>
<body>

<div id="div0" class="div0" onclick="sameSize(this,'div1');">
This is div0,click on me to make div1 the same size</div>
<div id="div1" class="div1">this is div1</div>

</body>
</html>


--
Rob
Jul 23 '05 #4
thanks for the help.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Fawke101 | last post by:
Hi There, I have a table with 3 rows. 1st has the table/column headers, 2nd contains the column data and the 3rd is where the loop for the SQL statement lies. I also have a JS sort function on...
22
by: Marek Mand | last post by:
How to create a functional *flexible* UL-menu list <div> <ul> <li><a href=""></li> <li><a href=""></li> <li><a href=""></li> </ul> </div> (working in IE, Mozilla1.6, Opera7 (or maybe even...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
0
by: kinane3 | last post by:
Mostly I need to figure if I'm wasting my time or if there is a way to do what I am trying to do. I am an intermediate to CSS at best so please don't flame me, just trying to do my job here. I...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
8
by: RomanRusso | last post by:
Hie everybody, Here at this forum I have found something what I was looking for - rotation of cells in html table, here is the link http://www.thescripts.com/forum/threadnav149304-2-10.html The...
2
by: davidson1 | last post by:
Hai friends..for menu to use in my website..i found in one website....pl look below website.... http://www.dynamicdrive.com/dynamicindex1/omnislide/index.htm i downloaded 2 files.... ...
5
by: Test | last post by:
Is it possibel to have DIV's inside a table cell so that their position can be given relative to top left corner of the cell. Now the DIVs seem to position themselves relative to previous object.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.