473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

I need to have a js function display in the current window but it opens a new window

I am using a fixed menu with dropdown options. I am using
Expand|Select|Wrap|Line Numbers
  1.  <a href="#"onclick="CreateTable()" target="_top">Link 1</a>
to keep it on the same page but it still goes to another window. What can I do?
Jan 21 '16 #1
6 5217
madankarmukta
308 256MB
set target = "_self"
Jan 24 '16 #2
Your suggestion didn't work. The table still goes to a new window instead of displaying in the window where the fixed menu is at. Thank you anyway. I tried to insert it in an Iframe along with the frame main and banner but the Iframe displayed inside of the Frame instead of the main frame.
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>
  5. ul { list-style-type: none;    margin: 0;    padding: 0;    overflow: hidden;    background-color: #333;}
  6. li {    float: left;}
  7. li a, .dropbtn {    display: inline-block;    color: white;    text-align: center;    padding: 14px 16px;    text-decoration: none;}
  8. li a:hover, .dropdown:hover .dropbtn {    background-color: #111;}
  9. .dropdown {    display: inline-block;}
  10. .dropdown-content {    display: none;    position: absolute;    background-color: #f9f9f9;    min-width: 160px;    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);}
  11. .dropdown-content a {    color: black;    padding: 12px 16px;    text-decoration: none;    display: block;}
  12. .dropdown-content a:hover {background-color: #f1f1f1}
  13. .dropdown:hover .dropdown-content {    display: block;}
  14. </style>
  15. <title>Fixed Menu Example</title>
  16. <script type="text/javascript" src="http://localhost/5040/PSC/zonesjs/includedata.js"></script>
  17. <script type="text/javascript" src="http://localhost/5040/PSC/Zonesjs/functions.js"></script>
  18.  
  19. </head>
  20. <body>
  21.  
  22. <ul>
  23.   <li><a class="active" href="#home">Home</a></li>
  24.   <li><a href="#news">News</a></li>
  25.   <div class="dropdown">
  26.     <a href="#" class="dropbtn">Dropdown</a>
  27.     <div class="dropdown-content">
  28.       <a href="javascript:CreateTable()" set target = "_self">Link 1</a>
  29.       <a href="#">Link 2</a>
  30.       <a href="#">Link 3</a>
  31.     </div>
  32.   </div>
  33. </ul>
  34.  
  35. <h3>Dropdown Menu inside a Navigation Bar</h3>
  36. <p>Hover over the "Dropdown" link to see the dropdown menu.</p>
  37.  
  38. <script type="text/javascript">
  39. function CreateTable(){
  40.     var needfooter;        
  41.     document.write("<table align='center' id='tblMain' border='1' >"); 
  42.     for (var i = 0;i<= 87;i++){
  43.         needFooter = true;
  44.         if (i % 8 == 0){document.write ("<tr>");}
  45.         document.write("<td><a HREF='javascript:DisplayConstellations(" + i + ");'>" + ConName[i] + "</a></td>");                          
  46.         if (i % 8 == 8){
  47.        document.write ("</tr>");
  48.            needFooter = false;}     
  49.      }
  50.      if (needFooter){document.write ("</td></tr>"); }
  51.     document.write ("</table>");
  52. }
  53. </script>
  54. </body>
  55. </html>
  56.  
Jan 24 '16 #3
madankarmukta
308 256MB
In order to open the html table in the same windows, did you try using windows.open with self.

Please let me know if this doesn't work.
Jan 24 '16 #4
That didn't work. Of course, I don't know what I am doing with the open window stuff. I looked it up on Internet and followed their example.
Expand|Select|Wrap|Line Numbers
  1. <ul>
  2.   <li><a class="active" href="#home">Home</a></li>
  3.   <li><a href="#news">News</a></li>
  4.   <div class="dropdown">
  5.     <a href="#" class="dropbtn">Dropdown</a>
  6.     <div class="dropdown-content">
  7.       <a href="javascript:callTable()">Link 1</a>
  8.       <a href="#">Link 2</a>
  9.       <a href="#">Link 3</a>
  10.     </div>
  11.   </div>
  12. </ul>
  13.  
  14. <h3>Dropdown Menu inside a Navigation Bar</h3>
  15. <p>Hover over the "Dropdown" link to see the dropdown menu.</p>
  16.  
  17. <script type="text/javascript">
  18. function callTable(){
  19. var myWindow = window.open("", "_self");
  20. myWindow.document.getElementById('main').contentWindow.CreateTable();
  21. }
  22.  
  23. function CreateTable(){
  24.     var needfooter;        
  25.     document.write("<table align='center' id='MyTable' border='1' >"); 
  26.     for (var i = 0;i<= 87;i++){
  27.         needFooter = true;
  28.         if (i % 8 == 0){document.write ("<tr>");}
  29.         document.write("<td><a HREF='javascript:DisplayConstellations(" + i + ");'>" + ConName[i] + "</a></td>");                          
  30.         if (i % 8 == 8){
  31.        document.write ("</tr>");
  32.            needFooter = false;}     
  33.      }
  34.      if (needFooter){document.write ("</td></tr>"); }
  35. document.write ("</table>");
  36.  
  37. }
  38.  
Jan 24 '16 #5
I have a fixedtop menu and a javascript function with one line to simplify things. The one line still goes to a new window. Right now it won't even submit when I click on "link".
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>
  5. body {margin:0;}
  6. ul {list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; 
  7. position: fixed; top: 0;  width: 100%;}
  8. li {float: left;}
  9. li a {display: block; color: white; text-align: center;  padding: 14px 16px;  text-decoration: none;}
  10. li a:hover:not(.active) { background-color: #111;}
  11. .active {    background-color: #4CAF50;}
  12. </style>
  13. <title>Fixed Menu Example</title>
  14. <script type="text/javascript">
  15. function pilotstarTable(){
  16.     parent.location.document.write("Hi John!");
  17. }
  18. </Script>
  19. </head>
  20. <body>
  21. <ul>
  22.   <li><a class="active" href="#home">Home</a></li>
  23.   <li><a href="javascript:pilotstarTable()">link</a></li>
  24.   <li><a href="#contact">Contact</a></li>
  25.   <li><a href="#about">About</a></li>
  26. </ul>
  27.  
  28. <div style="padding:20px;margin-top:30px;background-color:#1abc9c;height:1500px;">
  29. <h1>Fixed Top Navigation Bar</h1>
  30.  
Jan 25 '16 #6
I found this on w3schools.com. It works as long as I don't use a function with document.getElementById("demo").innerHTML = newDoc(); How can I submit the table if it will only run if the above code isn't in a function. When it is in a function the table goes to another page. I tried target="_self" and "_blank" and it still goes to a new window. I need to be able to display the table with the menu buttons not when the program starts.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>
  5. body {margin:0;}
  6. ul {list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; 
  7. position: fixed; top: 0;  width: 100%;}
  8. li {float: left;}
  9. li a {display: block; color: white; text-align: center;  padding: 14px 16px;  text-decoration: none;}
  10. li a:hover:not(.active) { background-color: #111;}
  11. .active {    background-color: #4CAF50;}
  12. </style>
  13. <title>Fixed Menu Example</title>
  14. <script type="text/javascript" src="http://localhost/5040/PSC/zonesjs/includedata.js"></script>
  15. <script type="text/javascript" src="http://localhost/5040/PSC/zonesjs/functions.js"></script>
  16. <script type="text/javascript">
  17. function newDoc() {
  18.     var needfooter;    var tmpArray=new Array();
  19.          for (var k = 0;k<= 87;k++)
  20. {tmpArray[k] = "<a HREF='javascript:DisplayConstellations(" + k + ");'>" + ConName[k] + "</a>";}
  21. document.write("<table border=1>"); 
  22.      for (var i = 0;i<= 87;i++){ 
  23.          needFooter = true;
  24.       if (i % 8 == 0){document.write("<tr>");     }
  25.            document.write ("<td>" + tmpArray[i] + "</td>");
  26.         }
  27.         if (i % 8 == 8){document.write ("</tr>"); needFooter = false;  }    
  28.      if (needFooter){document.write ("</td></tr>"); }
  29.     document.write ("</table>");
  30. }
  31. </script>
  32.  
  33. </head>
  34. <body>
  35. <p id="demo"></p>
  36. <script type="text/javascript">
  37. function DisplayTable(){
  38. document.getElementById("demo").innerHTML=newDoc();}
  39. </script>
  40. <ul>
  41.   <li><a class="active" href="#home">Home</a></li>
  42.   <li><a target="demo" href="#"onclick="DisplayTable()">PilotstarTable</a></li>
  43.   <li><a href="#contact">Contact</a></li>
  44.   <li><a href="#about">About</a></li>
  45. </ul>
  46.  
  47. <div style="padding:20px;margin-top:30px;background-color:#1abc9c;height:1500px;">
  48. <h1>Fixed Top Navigation Bar</h1>
  49. <h2>Scroll this page to see the effect</h2>
  50. <h2>The navigation bar will stay at the top of the page while scrolling</h2>
  51.  
  52. </div>
  53.  
  54.  
  55. </body>
  56. </html>
  57.  
  58.  
Jan 25 '16 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Marco Alting | last post by:
hi I have a javascript function, which gets parameters from a form and then opens a new form in another window. The new window also has a javascript function with parameters. My question is,...
4
by: Jianli Shen | last post by:
New c++:-) When look through code, I always find lot of funtions are declared as (in .h): static void function1(); when implementing,(in .cpp), just void function1(){ }
3
by: John Dalberg | last post by:
Hi I have a form that opens a new window for the results. Because the results might take a few seconds due to server processing, I would like to display a message "please wait" in the new...
5
by: Dave Hammond | last post by:
You'd think this would be a basic part of the window object (and perhaps it is and I'm just being dense), but I can't find any reference in the IE window object documentation to a property which...
10
by: Shang Wenbin | last post by:
Hi, When I want to close the current window using window.close() in IE6.0, there will be a confirm box that: The web page you are viewing is trying to close the window. Do you want to close this...
4
by: Csaba Gabor | last post by:
Up until a few weeks ago, javascript code like window.open("http://mydomain.com", "windowName"); would always bring my new or reused window to the top, with focus. Lately, Firefox (Deer park...
22
by: stephen | last post by:
I have created an order form that users javascript to create a new html document when the customers clicks the "print page" button. Once the new document has been created it then prints the...
11
by: Dave | last post by:
For some reason, the below lines only work on select machines. All machines are running IE6. IE SP's and OS's vary. When it doesn't work, default.aspx (the page that this code is in) opens and...
1
by: marc_donofrio | last post by:
I can move and resize the current window. I need a window that opens up with no Toolbars. I know how to achieve this from another window via a link. But is there a method to reload the current...
1
by: plumba | last post by:
I have a form which I would like to open in a window with no address bar, tool bar etc etc. I've used the below code for this: function delayer(){ newurl = "testpage.html"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.