473,385 Members | 1,355 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,385 software developers and data experts.

How do I create a menu that 'knows where it has been'

I am loading a frame on the right from a simple text menu in a frame on
the left.

What I would like is to be able to show the user which menu item they
selected last for example emboldening the item or showing a marker
against it.

Could anyone post a snippet of code or a link that might just point me
in the right direction.

Thanks in anticipation.

Casey

Oct 21 '05 #1
8 1009
casey wrote:
I am loading a frame on the right from a simple text menu in a frame on
the left.
Avoid frames in favor of positioned block elements where feasible.
What I would like is to be able to show the user which menu item they
selected last for example emboldening the item or showing a marker
against it.

Could anyone post a snippet of code or a link that might just point me
in the right direction.


Quick hack:

<script type="text/javascript">
function setStyleProperty(o, sProperty, value)
{
if (o
&& typeof o.style != "undefined"
&& typeof o.style[sProperty] != "undefined")
{
o.style[sProperty] = value;
}
}

var last = null;

function mark(e)
{
if (e)
{
var t = e.target || e.srcElement;
if (t && t.tagName.toLowerCase() == "a" && t.href)
{
if (!last)
{
setStyleProperty(last, 'fontWeight', '');
}

setStyleProperty(t, 'fontWeight', 'bold');
last = t;
}
}
}
</script>

<ul onclick="mark(event);">
<li><a href="foo">foo</a></li>
<li><a href="bar">bar</a></li>
</ul>
PointedEars
--
Bill Gates isn't the devil -- Satan made sure hell
_worked_ before he opened it to the damned ...
Oct 21 '05 #2
Thomas 'PointedEars' Lahn <Po*********@web.de> wrote:
casey wrote:
What I would like is to be able to show the user which menu item they
selected last for example emboldening the item or showing a marker
against it. Quick hack:
<script type="text/javascript">
function setStyleProperty(o, sProperty, value)
{
if (o
&& typeof o.style != "undefined"
&& typeof o.style[sProperty] != "undefined")
{
o.style[sProperty] = value;
}
}

var last = null;

function mark(e)
{


// hi Thomas,
// here I just do a little modification for non persistant mark :

if (e) {
var t = e.target || e.srcElement;
setStyleProperty(last, 'backgroundColor', '');
if (t && t.tagName.toLowerCase() == "a" && t.href) {
setStyleProperty(t, 'backgroundColor', 'yellow');
last = t;
}
}
}
</script>

<ul onclick="mark(event);">
<li><a href="foo">foo</a></li>
<li><a href="bar">bar</a></li>
</ul>


<!-- and here a precision for overlapping ul -->

<ul onclick="mark(event);">
<li><a href="01">01</a></li>
<li><a href="02">02</a></li>
<ul> <!-- no need onclick in overlapping ul -->
<li><a href="toto">toto</a></li>
<li><a href="titi">titi</a></li>
</ul>
<li><a href="03">03</a></li>
<li><a href="04">04</a></li>
</ul>
--
@@@@@
E -00 comme on est very beaux dis !
' `) /
|\_ =="
Oct 21 '05 #3
Thanks folks for this, just a little problem though, it is probably
caused by the fact that I am stuck with frames.

If run the script in my menu.htm standalone I get the yellow
background.

If I run it in firefox I get a neat outline round the menu item I just
clicked.

But [here goes ;] if I run it in IE I get no indication at all.

Any ideas ?

Thanks again

Casey

Oct 22 '05 #4
denisb wrote:
Thomas 'PointedEars' Lahn <Po*********@web.de> wrote:
Quick hack:
<script type="text/javascript">
function setStyleProperty(o, sProperty, value)
{
if (o
&& typeof o.style != "undefined"
&& typeof o.style[sProperty] != "undefined")
{
o.style[sProperty] = value;
}
}

var last = null;

function mark(e)
{


// hi Thomas,
// here I just do a little modification for non persistant mark :

if (e) {
var t = e.target || e.srcElement;
setStyleProperty(last, 'backgroundColor', '');
if (t && t.tagName.toLowerCase() == "a" && t.href) {
setStyleProperty(t, 'backgroundColor', 'yellow');
last = t;
}
}


Well, yes, since setStyleproperty() checks if the reference is valid,
one could skip the test in the calling function. But why unmark if
not clicked another menu item? I'd find that confusing as a user.
}
</script>

<ul onclick="mark(event);">
<li><a href="foo">foo</a></li>
<li><a href="bar">bar</a></li>
</ul>


<!-- and here a precision for overlapping ul -->

<ul onclick="mark(event);">
<li><a href="01">01</a></li>
<li><a href="02">02</a></li>
<ul> <!-- no need onclick in overlapping ul -->
<li><a href="toto">toto</a></li>
<li><a href="titi">titi</a></li>
</ul>
<li><a href="03">03</a></li>
<li><a href="04">04</a></li>
</ul>


I don't see your point.
PointedEars
Oct 22 '05 #5

Am I right in thinking that if I clicked on all the items without
resetting the last item I would end up with all menu items marked ?

I still have the problem I am afraid that although the code works fine
in a standalone (popup) scenario, in frames it partly works in FF in
that it leaves a mark around the selected item, in IE however, it does
nothing at all.

Any clues please ?

Casey

Oct 22 '05 #6
casey wrote:
Am I right in thinking that if I clicked on all the items without
resetting the last item I would end up with all menu items marked ?
Yes, you are.
I still have the problem I am afraid that although the code works fine
in a standalone (popup) scenario, in frames it partly works in FF in
that it leaves a mark around the selected item,
Works as designed. The "mark around" is for users navigating
with the keyboard. You should not try to change that.
in IE however, it does nothing at all.


Which is clearly a Bad Thing.
PointedEars
Oct 22 '05 #7

Thomas 'PointedEars' Lahn wrote:
casey wrote:
I still have the problem I am afraid that although the code works fine
in a standalone (popup) scenario, in frames it partly works in FF in
that it leaves a mark around the selected item,


Works as designed. The "mark around" is for users navigating
with the keyboard. You should not try to change that.


Sorry if I did not make myself clear, in FF the mark around is the only
thing that appears, (ie no yellow background - or emboldening in the
other guy's example)
in IE however, it does nothing at all.


Which is clearly a Bad Thing.


This is a disaster for me as a large proportion of my target
'readership' will be using ie.

Could this be something to do with the event happening as the page is
loading in the new frame ?

Thanks

Casey

Oct 23 '05 #8
casey wrote:
Thomas 'PointedEars' Lahn wrote:
casey wrote:
> I still have the problem I am afraid that although the code works fine
> in a standalone (popup) scenario, in frames it partly works in FF in
> that it leaves a mark around the selected item, Works as designed. The "mark around" is for users navigating
with the keyboard. You should not try to change that.


Sorry if I did not make myself clear, in FF the mark around is the only
thing that appears, (ie no yellow background -


Works for me. Is your `href' attribute value empty by any chance? In
that case `t.href' would evaluate to `false' in the boolean expression.
or emboldening in the other guy's example)
I think the "other guy" was me :)
> in IE however, it does nothing at all.

Which is clearly a Bad Thing.


This is a disaster for me as a large proportion of my target
'readership' will be using ie.


Misunderstanding. The Bad Thing was if no mark would be around the link
when selected.
Could this be something to do with the event happening as the page is
loading in the new frame ?


It could have something to do with several things.
It seems best you post the URL of a test case here.
PointedEars
Oct 23 '05 #9

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

Similar topics

2
by: gregory stevenson | last post by:
I am looking for a simple cascading menu javascript.One where it lives on the left side of the screen, listed vertically and when you select a menu item the list expands to show the sub menu items...
10
by: Richard | last post by:
The style sheet shown below is from the suckerfish vertical menu. http://www.htmldog.com/articles/suckerfish/dropdowns/example/vertical.html I've added in a few minor changes to color code the...
2
by: Gustavo Franco | last post by:
Hi, Basic Question, difficult answer 1) Thread one; Open Context Menu.
2
by: Angelos | last post by:
Hello anyone knows a good way to refresh a DropDown Select Menu after it has been updated ? It is a PHP dynamic populated menu. The user has the option to add a new category So he clicks the Add...
8
by: Brian S. Smith | last post by:
Hi gang, Please help. I've been through the Access help, searched the Web, and I can't seem to get a straight answer. As the Subject line suggests, I want to run a fairly simple VB/Access Sub...
6
by: Dave | last post by:
Hello there. I'm interesting how do I create server side menu in ASP.NET, I was searching for some menus, but they are all done with DHTML or JavaScript, so I have some problems to use them. I...
4
by: I_AM_DON_AND_YOU? | last post by:
There is one more problem I am facing but didn't get the solution. In my Setup Program I am not been able to create 2 things (when the program is intalled on the client machine ) : (1) create...
2
by: ishtar2020 | last post by:
Hi everybody I'd appreciate some help on creating a tear off menu with TkInter. I've been reading some documentation but still no luck. Please don't get confused: when I mean "tear off" menu I...
1
by: Preeti | last post by:
Hi all I am a fresher and have been given a requirement in VB.net I have to make an application in VB.net which will run as a system tray icon and will add one or two items in the default...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.