473,587 Members | 2,533 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

38 New Member
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 5228
madankarmukta
308 Contributor
set target = "_self"
Jan 24 '16 #2
John Alexander
38 New Member
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 Contributor
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
John Alexander
38 New Member
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
John Alexander
38 New Member
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
John Alexander
38 New Member
I found this on w3schools.com. It works as long as I don't use a function with document.getEle mentById("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
6512
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, how can I send the variable values from one function to another in a new window? Thanks, Marco
4
1779
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
4623
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 window, erase that message when the processing is done and show the results. How is this done? John Dalberg
5
6469
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 returns the current window height/width. I can't check Mozilla, as the site is currently unresponsive, but i don't recall there being any mention of...
10
37982
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 window? I have to click yes to close the window. How can I close the current window directly without this dialog box? Thank you.
4
3593
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 alpha 2) only brings it to the top if the window is new. If it's being reused, the window does not come to the foreground (with IE 6 it does). Is...
22
130084
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 document and closes it with the following code: <body onload="window.print(); window.close();"> This works correctly (or at least the way I expect...
11
4920
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 closes. That's all you see. TSReminder.aspx doesn't even open. I'm not sure what's going on here. Response.Write("<script...
1
1374
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 window with no tool bars.
1
1919
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" window.open(newurl,'mywindow','width=1024,height=768,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes'); } ...
0
7852
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.