?
Solved

mm_menu.js with aspx - unable to retrieve element object , returning undefined

Posted on 2007-12-05
4
Medium Priority
?
740 Views
Last Modified: 2013-11-19
Hi guys,

I'm trying the dynamic menu on .aspx, but its not working as it did in .asp.
I have no problem creating span layer and add submenu on it in asp.
script.js file
function FIND(item) {
      if( window.mmIsOpera ) return(document.getElementById(item));
      if (document.all)  return(document.all[item]); <-- return undefined when i use it on aspx
      if (document.getElementById) return(document.getElementById(item));
      
       return(false);
}
function writeMenus(container)
{
  ...
document.writeln('<span id="menuContainer"  ></span>'); <-- this seems not working in aspx
container = FIND("menuContainer");
alert('hey'+container);  <-- undefined..
...
}

aspx file (c#)
<script src="../includes/scripts.js" type="text/javascript"></script>
<%
String section = "Main Menu";                        
String subsection       = "stest";                        
String detail             = "img.jpg";            
%>
<script type="text/javascript">
<!--
section       = "<%=section%>";
subsection       = "<%=subsection%>";
detail             = "<%=detail%>";
// -->
</script>
<script type="text/javascript">mmLoadMenus();</script>
</HEAD>
<body onload="javascript:setnav('<%=section%>', '<%=subsection%>', '<%=detail%>');">

the js file i used is from :Andy Finnell, March 2002, mm_menu 20MAR2002 Version 6.0

Thanks for the help
0
Comment
Question by:crabbear
[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
  • 3
4 Comments
 
LVL 17

Accepted Solution

by:
gops1 earned 500 total points
ID: 20416914
Strange but works when I add some content:

document.writeln('<span id="menuContainer">&nbsp;</span>');
0
 

Author Comment

by:crabbear
ID: 20416986
ya thats why im puzzled. urs work in aspx? prehaps u post ur aspx code for me to reference?
In my main aspx file, i include
<script src="../includes/scripts.js" type="text/javascript"></script>
            <%
                  String section       = "EmployeeBasics";                        
                  String subsection       = "NewEmployees";                        
                  String detail             = "img-passportVISA.jpg";            
            %>
            <script type="text/javascript">
            <!--
                  section       = "<%=section%>";
                  subsection       = "<%=subsection%>";
                  detail             = "<%=detail%>";
                  document.writeln('<span id="menuContainer"  ></span>');
                  var span = document.getElementById("menuContainer");
                  alert(span);
            // -->
            </script>
            <script type="text/javascript">mmLoadMenus();</script>
      </HEAD>
      <body
onload="javascript:setnav('<%=section%>', '<%=subsection%>', '<%=detail%>');"MS_POSITIONING="GridLayout">

and this in my body tag
<!-- #include virtual="/aphr/includes/topnav.aspx" -->

my topnav.aspx display all the menus
0
 

Author Comment

by:crabbear
ID: 20416990
i tried adding:
document.writeln('<span id="menuContainer"  ></span>');
var span = document.getElementById("menuContainer");
alert(span);
as u can see from above.
But it returns null. im stuck

0
 

Author Comment

by:crabbear
ID: 20417000
OH MY GOD...
now it works..
and I dont know why...

Works in asp, BUT not in aspx
document.writeln('<span id="menuContainer"  ></span>');  

Works in BOTH asp and aspx
document.writeln('<span id="menuContainer">&nbsp;</span>');

Crazy browser..
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

764 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