Solved

XML Nav bar

Posted on 2004-08-13
7
270 Views
Last Modified: 2008-03-03
My question deals with XML and flash, so I hope I can post this question here.
I did a drop down menu using xml and I was able to use flash but I can link my home button to my home page. This is the code.

vb<?xml version="1.0"?>
<NAV main_onColor="#000000" main_offColor="#ff6600" sub_onColor="#000000" sub_offColor="#666666" navWidth="150" fadeTime="0" lineWidth="150" main_y_padding="4" sub_y_padding="2" sub_indent="10">
   <MAIN text="HOME" URL="home.html" expand="true" >
      <SUB text="Current State" URL="currentstate.html"></SUB>
      <SUB text="Mission" URL="mission.html"></SUB>
        <SUB text="Who We Are" URL="whoweare.html"></SUB>
      <SUB text="Background" URL="background.html"></SUB>
         <SUB text="Leadership" URL="leadership.html"></SUB>
      <SUB text="World Policy Philosophy" URL="worldpophil.html"></SUB>
   </MAIN>
</NAV>
0
Comment
Question by:Isaac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 26

Expert Comment

by:rdcpro
ID: 11798154
I could be wrong, but I don't think it's possible to do an expand and navigate using the prepackaged actionscript for the Menu.  But if you want, you can create a separate expanding container for the subs, like:


<?xml version="1.0"?>
<NAV main_onColor="#000000" main_offColor="#ff6600" sub_onColor="#000000" sub_offColor="#666666" navWidth="150" fadeTime="0" lineWidth="150" main_y_padding="4" sub_y_padding="2" sub_indent="10">
   <MAIN text="HOME" URL="home.html" expand="true" ></MAIN>
   <MAIN text="About" expand="true">
      <SUB text="Current State" URL="currentstate.html"></SUB>
      <SUB text="Mission" URL="mission.html"></SUB>
       <SUB text="Who We Are" URL="whoweare.html"></SUB>
      <SUB text="Background" URL="background.html"></SUB>
        <SUB text="Leadership" URL="leadership.html"></SUB>
      <SUB text="World Policy Philosophy" URL="worldpophil.html"></SUB>
   </MAIN>
   <MAIN text="Some Other Category" URL="mycategory.html"></MAIN>
</NAV>

etc.

Regards,
Mike Sharp
0
 
LVL 5

Author Comment

by:Isaac
ID: 11836794
I TRIED that Mike but it didn't show my sub menu. It only showed the home. Thanks anyway.
0
 
LVL 26

Expert Comment

by:rdcpro
ID: 11837157
Something is strange here, because it should have shown a "Home" and an "About".  You click on home, it goes home, you click on About and it epands to show the Subs for About...I did notice a small mistake in my code. This tag:
   <MAIN text="HOME" URL="home.html" expand="true" ></MAIN>
should have been like:
   <MAIN text="HOME" URL="home.html" ></MAIN>

Like so:

<?xml version="1.0"?>
<NAV main_onColor="#000000" main_offColor="#ff6600" sub_onColor="#000000" sub_offColor="#666666" navWidth="150" fadeTime="0" lineWidth="150" main_y_padding="4" sub_y_padding="2" sub_indent="10">
   <MAIN text="HOME" URL="home.html" ></MAIN>
   <MAIN text="About" expand="true">
      <SUB text="Current State" URL="currentstate.html"></SUB>
      <SUB text="Mission" URL="mission.html"></SUB>
      <SUB text="Who We Are" URL="whoweare.html"></SUB>
      <SUB text="Background" URL="background.html"></SUB>
      <SUB text="Leadership" URL="leadership.html"></SUB>
      <SUB text="World Policy Philosophy" URL="worldpophil.html"></SUB>
   </MAIN>
   <MAIN text="Some Other Category" URL="mycategory.html"></MAIN>
</NAV>

The problem is you're wanting a click on Home to both navigate to another page, and expand the category, which are mutually exclusive actions.

Regards,
Mike Sharp
0
Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

 
LVL 5

Author Comment

by:Isaac
ID: 11895977
I don't think this will work. I want the home to go to the home page and expand at the same time.
0
 
LVL 26

Expert Comment

by:rdcpro
ID: 11897435
Right, but that doesn't make sense, does it?  The problem is you're wanting a click on Home to both navigate to another page, and expand the category, which are mutually exclusive actions.   If you did this in straight HTML, you can have both an onclick and an href on an anchor tag.  The onclick is executed first, then the page navigates...which loses the original result of the onclick.  

You'd somehow need to maintain the state of the menu (with a query string, probably) so that when you navigate to the home page, your menu is then shown expanded.   I've seen this done with frames (because you're actually navigating a separate frame, not the one with the menu).

Regards,
Mike Sharp

0
 
LVL 5

Author Comment

by:Isaac
ID: 11903388
I will give you the points if you tell me what is the code in straight HTML?
0
 
LVL 26

Accepted Solution

by:
rdcpro earned 500 total points
ID: 11904369
Here is home.html

<html>
<head>
<script language="JScript">
      function toggle()
      {
            if (target.style.display == "none")
            {
                  // display the hidden div
                  target.style.display = "";
            }
            else
            {
                  // hide the div
                  target.style.display = "none";
            }
      }
</script>
</head>
<body>
<a href="about.html" onclick="toggle()">Go back to about</a>
<br>
<a href="#" onclick="toggle()">Toggle without navigating</a>
<div id="target" style="display:none;">
      <h1>Now you see me</h1>
</div>
</body>
</html>

here is about.html:

<html>
<head>
<script language="JScript">
      function toggle()
      {
            if (target.style.display = "none")
            {
                  // display the hidden div
                  target.style.display = "";
            }
            else
            {
                  // hide the div
                  target.style.display = "none";
            }
      }
</script>
</head>
<body>
<a href="home.html" onclick="toggle()">Go Home</a>
<br>
<a href="#" onclick="toggle()">Toggle without navigating</a>
<div id="target" style="display:none;">
      <h1>Now you see me</h1>
</div>
</body>
</html>

As you can see, it's not possible to BOTH display the hidden div AND navigate away from the page that has the hidden div.  Think about it!  If you click the link to go back and forth, sometimes--just for an instant--you'll see the div appear.

What you need is a *SEPARATE* link to do the expanding and collapsing, like:

<html>
<head>
<script language="JScript">
      function toggle()
      {
            if (target.style.display == "none")
            {
                  // display the hidden div
                  target.style.display = "";
            }
            else
            {
                  // hide the div
                  target.style.display = "none";
            }
      }

      function switchText(o)
      {
            if (target.style.display == "none")
            {
                  o.innerText = "-";
            }
            else
            {
                  o.innerText = "+";
            }
            toggle();
      }
</script>
</head>
<body>
<span onclick="switchText(this)" style="color:blue;width:1em;cursor:hand;">+</span>
<a href="home.html" onclick="toggle()">Go Home</a>
<div id="target" style="display:none;">
      <h1>Now you see me</h1>
</div>
<br>
<a href="#" onclick="toggle()">Toggle without navigating</a>
</body>
</html>

But your canned actionscript doesn't have that capability...you have to decide which you want; navigate or expand.

By the way, the above code is not necessarily cross-browser.  It's just to illustrate the concept.

Regards
Mike Sharp
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question