473,756 Members | 2,996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2438
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,Helvetic a", 9, "bold",
"bold", "white", "white", 0, "white", 2,
"rollover:image s/tri-down1.gif:image s/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 (getComputedSty le) 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.getEle mentById(b);

// Zilla stuff
if (window.getComp utedStyle) {
var h = document.defaul tView.getComput edStyle(a,
'').getProperty Value('height') ;
var w = document.defaul tView.getComput edStyle(a,
'').getProperty Value('width');
msg += '\ngetComputedS tyle (h,w): ' + h + ', ' + w;

// IE stuff
} else if (a.currentStyle ) {
var h = eval('a.current Style.height');
var w = eval('a.current Style.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="sameSi ze(this,'div1') ;">
This is div0,click on me to make div1 the same size</div>
<div id="div1" class="div1">th is 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
1470
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 there (which int complete, but thats another post/story) which sorts the data A-Z or Z-A. The problem i am having is that the loop row (which isnt visible on the ASP page, as its ASP) is being sorted as well.
22
11094
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 in Opera6))
7
3615
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> </head> <style type="text/css">
0
1285
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 came across this article when I searched for a CSS solution to long winded DHTML dropdown menus. http://www.alistapart.com/articles/dropdowns/ I did get it to work but here's my problem. What I "did" get to work was a horizontal drop in a...
8
3674
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
8
4315
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 gue named RobD posted a nice script there. You can easily modify it for the needs of your table, but one problem occured on my way, maybe somebody can help. For instance if there is <a> tags inside one table cell, the script willl rotate only the...
2
2465
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.... menuitems.js mmenu.js
5
3637
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
9431
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9255
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10014
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9844
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9689
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7226
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5119
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3780
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3326
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.