i am trying to create a simple switch to turn the main navigation of a site "on" and "off". here is my script:
i am getting these errors:
-from firefox-
"Error: nav_display() is not defined"
-from IE-
"Error: Object expected"
this is essentially a carbon copy of another function i was using in another spot on the site. which works fine. or should at least. it's not working for me now either. do i maybe have something wrong on my machine? this seems like elementary JS and DOM manipulation. i am confoozled.. in all fairness, it is 2:20 AM..
Code:
function nav_display() { // show/hide nav if (document.getElementById('sidebar').style.display == 'none') { document.getElementById('sidebar').style.display = 'block'; document.getElementById('content').style.margin-left = '1.5em'; document.getElementById('nav_display_a').style.color = '#666'; } else { document.getElementById('sidebar').style.display = 'none'; document.getElementById('content').style.margin-left = '170px'; document.getElementById('nav_display_a').style.color = '#FFF'; } } <div id="nav_display_btn"> <a id="nav_display_a" href="javascript:;" onclick="nav_display()" title="Click to show/hide the main menu.">«</a> </div>
-from firefox-
"Error: nav_display() is not defined"
-from IE-
"Error: Object expected"
this is essentially a carbon copy of another function i was using in another spot on the site. which works fine. or should at least. it's not working for me now either. do i maybe have something wrong on my machine? this seems like elementary JS and DOM manipulation. i am confoozled.. in all fairness, it is 2:20 AM..

Comment