R
Reinhold Schrecker
Hi there,
I am trying to generate a dynamic menu with JavaScript/DOM and have
problems to set the onclick-attribute for my <a>-elements.
The following code works fine in Opera and Mozilla but does not work in
IE:
<!--snip-->
<script language="JavaScript">
<!-- //
var topArray = new Array();
var j = topArray.length;
topArray[j] = new Object();
topArray[j]["id"] = "funktion_466";
topArray[j]["class"] = "top-function";
topArray[j]["a_id"] = "466";
topArray[j]["a_class"] = "menu-left-tab";
topArray[j]["a_onclick"] = "
top.open('wrap_action_frame?setup_dynamic_frame%3Fpar_session=1676053637&par_session=1676053637',
'dynamic1676053637'); return false;";
topArray[j]["a_text"] = "Search";
var myCurrentElement;
var myNewElement;
var myNewChildElement;
var myNewChildText;
function buildMenu(parameter)
{
myCurrentElement = window.document.getElementById('topmenu');
for (var i = 0; i < topArray.length; i++)
{
myNewElement = window.document.createElement('div');
myNewElement.className = topArray["class"];
myNewElement.setAttribute('id', topArray["id"]);
myNewChildElement = window.document.createElement('a');
myNewChildElement.setAttribute('id', topArray["a_id"]);
myNewChildElement.className = topArray["a_class"];
myNewChildElement.setAttribute('href', topArray["href"]);
myNewChildElement.setAttribute('target', topArray["target"]);
myNewChildElement.setAttribute(''onClick'',
topArray["a_onclick"]);
}
}
buildMenu();
// -->
</script>
<!--snip-->
Regards
Reinhold
I am trying to generate a dynamic menu with JavaScript/DOM and have
problems to set the onclick-attribute for my <a>-elements.
The following code works fine in Opera and Mozilla but does not work in
IE:
<!--snip-->
<script language="JavaScript">
<!-- //
var topArray = new Array();
var j = topArray.length;
topArray[j] = new Object();
topArray[j]["id"] = "funktion_466";
topArray[j]["class"] = "top-function";
topArray[j]["a_id"] = "466";
topArray[j]["a_class"] = "menu-left-tab";
topArray[j]["a_onclick"] = "
top.open('wrap_action_frame?setup_dynamic_frame%3Fpar_session=1676053637&par_session=1676053637',
'dynamic1676053637'); return false;";
topArray[j]["a_text"] = "Search";
var myCurrentElement;
var myNewElement;
var myNewChildElement;
var myNewChildText;
function buildMenu(parameter)
{
myCurrentElement = window.document.getElementById('topmenu');
for (var i = 0; i < topArray.length; i++)
{
myNewElement = window.document.createElement('div');
myNewElement.className = topArray["class"];
myNewElement.setAttribute('id', topArray["id"]);
myNewChildElement = window.document.createElement('a');
myNewChildElement.setAttribute('id', topArray["a_id"]);
myNewChildElement.className = topArray["a_class"];
myNewChildElement.setAttribute('href', topArray["href"]);
myNewChildElement.setAttribute('target', topArray["target"]);
myNewChildElement.setAttribute(''onClick'',
topArray["a_onclick"]);
}
}
buildMenu();
// -->
</script>
<!--snip-->
Regards
Reinhold