Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6945139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:23:51+00:00 2026-05-27T13:23:51+00:00

I am making a XML-driven homepage. A menu structure is generated and when clicking

  • 0

I am making a XML-driven homepage. A menu structure is generated and when clicking on an menu element the content on the page is changed. When clicking on a level x element, its child is presented in a list in the main div. This is done by a function, changePage(id), that takes an id as argument to find correct XML-node to get the information.

I want this list elements to be links and when clicked on they should call changePage-function. This is used to step down in the tree.

var root = loadXML(aXML.xml);

function changePage(id){
var current_node = root;  // <-- here I get error when clicking on the a-element.
... // creating list
var aElement = document.createElement('a');
aElement.onclick = new Function("changePage('" + index + "')");
}

When I click on my menu item everything works but when I click on the generated list-element I get an error that “current_node is not defined”. It seemse that root-variable cant be found when clicking on child.

What is wrong and what can i do to solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:23:52+00:00Added an answer on May 27, 2026 at 1:23 pm

    Hi from what you have there you are killing the browser with new Functions ( overwriteing the old one )

    Instead of:

     aElement.onclick = new Function("changePage('" + index + "')");
    

    you could use:

     aElement.onclick = arguments.callee(index);
    

    “arguments” is a keyword in js and contains an object with all the parameters passed to the function ( i.e. arguments[0] ) and also contains “callee” (the function itself) and “caller” (the function from which is called ). The second one (caller) is not cross-browser.

    Best regards,

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that is making an XML POST-Request to an URL on
I am making a CSS file for an XML document. I need to insert
I’m making a simple LOB app which loads data from an XML file and
I need help making AOP work. What am I missing here? <?xml version=1.0 encoding=UTF-8?>
Are these nested comments allowed in a XML file? <!-- Making only one observation
As far as I know I can access the web.xml <context-param> s by making
I'm making a small tool for checking the material number from the XML file.
I need to have my XSLT stylesheet sort my XML file's child nodes, but
I'm making an Android application that reads an XML Internet. This application uses SAX
I'm making a custom XML layout to display a cocktail recipe. Here is my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.