Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Javascript problem

Javascript problem

Scheduled Pinned Locked Moved Web Development
javascripthtmldatabasetoolshelp
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Broken Bokken
    wrote on last edited by
    #1

    I'm making a simple html page with an external .js file that will write the navigation to a page. My problem is that for some reason the page will not call the function in the external file from the page. Here is my .js file: function WriteMenu(selectedNav) { document.writeln('<table id="NavigationTable">'); document.writeln('<tr>'); document.writeln(GetNavItem('Home', 'index.html', selectedNav == 'home')); document.writeln(GetNavItem('History', 'history.html', selectedNav == 'history')); document.writeln(GetNavItem('Castes', 'castes.html', selectedNav == 'castes')); document.writeln(GetNavItem('Map', 'Library/Images/map.gif', selectedNav == 'map')); document.writeln(GetNavItem('Rules', 'rules.html', selectedNav == 'rules')); document.writeln(GetNavItem('Resources', 'resources.html', selectedNav == 'resources')); document.writeln('<tr>'); document.writeln('</table>'); } function GetNavItem(text, url, isSelected) { var navItem; if (isSelected) { navItem = '<td class="selected"><a href="' + url + '">' + url + '<a></td>'; } else { navItem = '<td><a href="' + url + '">' + url + '<a></td>'; } return navItem; } Here are the answers to obvious questions. Here is my header: <script language="Javascript" type="text/javascript" src="Library/JS/Menu.js" /> Here is where I am trying to call the function. This is inside the body tags for the page. <script type="text/javascript"> WriteMenu('home'); </script> I even tried adding an alert to the function and I get nothing. Why won't it call the functions?

    Broken Bokken You can't carry out a ninja-style assasination dressed as an astronaut. It's the luminous fabric; too visible. - Tripod The story of your fighting is a poem of two words: YOU SUCK.

    N 1 Reply Last reply
    0
    • B Broken Bokken

      I'm making a simple html page with an external .js file that will write the navigation to a page. My problem is that for some reason the page will not call the function in the external file from the page. Here is my .js file: function WriteMenu(selectedNav) { document.writeln('<table id="NavigationTable">'); document.writeln('<tr>'); document.writeln(GetNavItem('Home', 'index.html', selectedNav == 'home')); document.writeln(GetNavItem('History', 'history.html', selectedNav == 'history')); document.writeln(GetNavItem('Castes', 'castes.html', selectedNav == 'castes')); document.writeln(GetNavItem('Map', 'Library/Images/map.gif', selectedNav == 'map')); document.writeln(GetNavItem('Rules', 'rules.html', selectedNav == 'rules')); document.writeln(GetNavItem('Resources', 'resources.html', selectedNav == 'resources')); document.writeln('<tr>'); document.writeln('</table>'); } function GetNavItem(text, url, isSelected) { var navItem; if (isSelected) { navItem = '<td class="selected"><a href="' + url + '">' + url + '<a></td>'; } else { navItem = '<td><a href="' + url + '">' + url + '<a></td>'; } return navItem; } Here are the answers to obvious questions. Here is my header: <script language="Javascript" type="text/javascript" src="Library/JS/Menu.js" /> Here is where I am trying to call the function. This is inside the body tags for the page. <script type="text/javascript"> WriteMenu('home'); </script> I even tried adding an alert to the function and I get nothing. Why won't it call the functions?

      Broken Bokken You can't carry out a ninja-style assasination dressed as an astronaut. It's the luminous fabric; too visible. - Tripod The story of your fighting is a poem of two words: YOU SUCK.

      N Offline
      N Offline
      NeverHeardOfMe
      wrote on last edited by
      #2

      Don't ask me why, but try replacing

      with

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups