How do you open a new window from a new window?

I am trying to open a new window from within a recently opened window. ie. From the main window (win1), I have opened an new informational window(win2). From within that new window a would like to open another smaller window(win3). All I get is the page for win3 loaded in win2.
awebdAsked:
Who is Participating?
 
mgfranzConnect With a Mentor Commented:
I guess myprevious answer didn't get posted...

Here is the answer;



                   <html>
                   <head>
                   <script>

                     function openScripter(){
                     Win2 = window.open('page2.htm','1','width=500,height=300,left=5,top=5')

                     }

                   </script>
                   </head>

                   <body>
                   <input type="button" value="help" onClick="openScripter()">


                   </body>
                   </html>

                   Page2.htm;

                   <html>
                   <head>
                   <script>
                   function showScript(){
                     Win3 =
                   window.open('home.asp','2','width=500,height=300,left=5,top=35')
                    }
                   </script>
                   </head>

                   <body>


                   <input type="button" value="help" onClick="showScript()">
                   </body>
                   </html>

You will see there is now a 'name' associated with each new window... Javascript needs to know which window to refreence,  I.E. no name no new window...

mark
0
 
mgfranzCommented:
How are you trying to open the win3 window?  You can open as many windows as you want providing the naming convention is not duplicated.

I assume you are using JavaScript to initiate the Window.Open() event.  In such case you will need to state what you want loaded into the window, page3.htm for example, you can call the event as such;

<script>

var w = window.open("page3.htm")
var x=0 ,y=0
w.moveTo(x,y);
</script>

This will open a new window with page3 as the contents, position 0,0 on the screen.

Hope this helps.

Mark
0
 
cheekycjCommented:
also (mgfranz omitted) that you can set options for the new
 window...
var w= window.open("source.html","window-name","height=x,width=y,
toolbar=no,location=no,..... and so on");

:-)

CJ
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
awebdAuthor Commented:
Here is the code I have:
// Window 1 (Main browser window)
  function openScripter(){
  Win2 = window.open('/toolbox/win2.html','','width=500,height=300,left=5,top=5')
  }

So far so good...

// Window2 (The window generated from above script)
 function showScript(){
  Win3 = window.open('/toolbox/win3.html','','width=500,height=300,left=5,top=35')
 }

When this is called it loads the page in the same window (Window2) instead of opening a new window (Window3).
0
 
ESICommented:
The clue is the "Set oNavWin.opener = self"

Hope it helps
c ya aroun'

Emmanuel

<HTML>
<HEAD>
<SCRIPT LANGUAGE="vbscript">  <!--

  'Dim a local variable to hold a reference to the new window.
  Private oNavWin

  Function OpenNavWindow()
'Call the open method and assign the resultant window reference to your local variable.
      Set oNavWin = Window.open("nav.html","navwindow", _
        "height=150,width=250, _
        status=yes,toolbar=no, _
        menubar=no,location=no,fullscreen=yes")
      'Pass a reference to this window to the new window.
      Set oNavWin.opener = self
  End Function

  Function CloseNavWindow()
      'Handle an error, just in case the
      'window has already been closed!
    on error resume next
      'Close the window.
    oNavWin.Close()
      'Release the object reference.
    Set oNavWin = Nothing
  End Function

//--></SCRIPT>
<SCRIPT LANGUAGE="JavaScript"> <!--
function openAppli(URL) { window.open(URL,"Appli", "toolbar=yes,location=no,menubar=yes"); }
//--></SCRIPT>

</HEAD>
<BODY>
<CENTER>
<H2>Main window</H2>
<P>
  <input type="button" name="cmdClose" onClick="CloseNavWindow" value="Close navigation window">
<P>
  <input type="button" name="cmdOpen" onClick="OpenNavWindow" value="Open navigation window">
</CENTER>
</BODY>
</HTML>
0
 
awebdAuthor Commented:
ESI,
Sorry, don't know vbscript at all. Got a JavaScript answer?
0
 
mgfranzCommented:
How are you calling showScript()?

Do you want this window3 to open upon window2 opening?

Mark
0
 
awebdAuthor Commented:
window3 opens on a clicked button:
<input type="button" value="help" onClick="showScript()">
0
 
mgfranzCommented:
Using your scripts, I created the following pages.  Page1.htm;

<html>
<head>
      <script>
      
  function openScripter(){
  Win2 = window.open('page2.htm','','width=500,height=300,left=5,top=5')
  }

</script>
</head>

<body>
<input type="button" value="help" onClick="openScripter()">


</body>
</html>

Page2.htm;

<html>
<head>
<script>
      function showScript(){
  Win3 = window.open('home.asp','','width=500,height=300,left=5,top=35')
 }
</script>
</head>

<body>


<input type="button" value="help" onClick="showScript()">
</body>
</html>

I had no problem whatsoever... opening all three windows.

Mark
0
 
awebdAuthor Commented:
mgfranz,
I just copied yout code doing nothing more than adding the form so the button will show and changing the URL of home.asp to a page I have. When I tried this all it did was load the 3rd page in the same window and move the window to the new positioning. I am using NN 4.51. Any ideas?
0
 
awebdAuthor Commented:
If you would like to see what it was I was working on, check out
www.awebd.net/toolbox
Check out the Scripter.
It isn't very pretty it should it my needs.
Thanks for all the help,
Cliff
0
All Courses

From novice to tech pro — start learning today.