How can I keep javascript function from displaying in a new window?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • John Alexander
    New Member
    • Dec 2011
    • 38

    How can I keep javascript function from displaying in a new window?

    I just found css code for a fixed menu at the top of the browser so the window under the menu can scroll right on without disturbing the menu. I used
    Code:
    <a href="javascript:CreateTable()"> </a>
    but the table displayed in a new window and I want it to stay in the window that the menu is on. I was using a frame before but I couldn't get the table to display in the main window so now I thought with this CSS code, it would behave itself. Can anyone tell me what I need to do to get subs and functions to display in the menu window? It will be used in aspx.vb eventually
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    first thing is to not use a link when you do not want to link something. having the cursor change its shape can be easily done in CSS.

    Code:
    <span onclick="CreateTable()"> </span>

    Comment

    • John Alexander
      New Member
      • Dec 2011
      • 38

      #3
      ok Thank you. Where in the code do I place <span onclick="Create Table()"> </span>?
      The menu has
      Code:
       <ul>
        <li><a class="active" href="#home">Home</a></li>
        <li><a href="javascript:CreateTable()">Table</a></li>
        <li><a href="#contact">Contact</a></li>
        <li><a href="#about">About</a></li>
      </ul>
      I didn't know how to submit the js function so I called a html file with CreateTable in javascript.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        where you had that link before.

        Comment

        • John Alexander
          New Member
          • Dec 2011
          • 38

          #5
          It didn't show up as a menu item to click on.
          Code:
          <style>
          body {margin:0;}
          ul {list-style-type: none; margin: 0;  padding: 0; overflow: hidden; background-color: #333; position: fixed; top: 0; width: 100%;}
          li {float: left;}
          li a {display: block; color: white;  text-align: center;   padding: 14px 16px; text-decoration: none;}
          li a:hover:not(.active) { background-color: #111;}
          .active {background-color: #4CAF50;}
          </style>
          </head>
          <body>
          <ul>
            <li><a class="active" href="#home">Home</a></li>
            <li><span onclick="CreateTable()"></span></li>
            <li><a href="#contact">Contact</a></li>
            <li><a href="#about">About</a></li>
          </ul>
          <div style="padding:20px;margin-top:30px;background-color:#FFFFFF;height:1500px;">
          <h1>Fixed Top Navigation Bar</h1>
          <h2>Scroll this page to see the effect</h2>
          <h2>The navigation bar will stay at the top of the page while scrolling</h2>
          </div>
          Last edited by John Alexander; Jan 21 '16, 05:14 PM. Reason: I forgot the closing [/code]

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            well, a tag with no content in it certainly does not show.

            Comment

            • John Alexander
              New Member
              • Dec 2011
              • 38

              #7
              I put Table in it and it didn't show up in the menu to be clicked. I have never used span before so I don't know the procedure. I just want a menu to display html table with 88 clickable cells. I have the table but can't get it to display in same window as menu.
              Code:
              <li><span onclick="CreateTable()">Table</span></li>

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                do you have a live page for testing?

                PS. you need to repeat the styling that you make for these <a> for the <span> as well

                Comment

                • John Alexander
                  New Member
                  • Dec 2011
                  • 38

                  #9
                  I use IIS 8 and have localhost to use a browser to run my code. I have aspx files and html files. html work fine except I end up with the html table with 88 cells in the frame and not in the main window just like it does in aspx.vb. code. I tried parent.main.loc ation.CreateTab le.html but it displays in the main window but the cells are not clickable so I can't use the next function which relies on which cell was clicked.

                  Comment

                  Working...