Forum Moderators: open

Message Too Old, No Replies

Opening multiple fitted windows

Opening multiple fitted windows

         

paulchwd1

5:53 pm on Nov 5, 2004 (gmt 0)

10+ Year Member



I know how to create fitted windows in javaScript via:

function openWin(page)
{
myWin= open(page, "popupWindow",
"width=475,height=670,status=no,toolbar=no,scrollbars=yes,menubar=no,screenX=0,screenY=0,");
}

and then

<a href="javaScript:openWindow('path to file')">Link Name</a>

problem: only one can be opened at a time, how can i tweak the code so that i can have multiple of these fitted windows at the same time

[edited by: BlobFisk at 6:37 pm (utc) on Nov. 5, 2004]
[edit reason] Disabled Smilies to make code readable! [/edit]

Rambo Tribble

3:00 am on Nov 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are going to name the windows you will need multiple window names. This example, however, shows windows with no names, just variable assignments. Your specific needs would determine whether it is more efficient to use just names, just variable assignments, or both.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<script type="text/javascript">
var wins=new Array(4);
var wins_ln=wins.length;
for(var i=0;i<wins_ln;i++){
var pad=i*10;
wins[i]=window.open("","","height=200px,width=300px,left="+pad+",top="+pad)
}
</script>
</body>
</html>

By the way, screenX & screenY in the window.open features context is for NN 4. The feature attributes left and top are more widely supported.

tedster

9:44 am on Nov 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also, for simplicity in your script, once any single feature parameter is assigned in the window.open() function, all the other features should default to "no"-- so you only need to mention the features you want to turn on for the new window.

mincklerstraat

12:30 pm on Nov 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a somewhat similar question, so I'll just post it to this thread.

I'm writing an app that's sort of a 'monitor' kind of thing and opens a window and writes diagnostic info to that window. It does this by opening a file called err.html that just does

onLoad=opener.update();
- and the function
update
is just does
windowHandler.document.open
and a long string of
windowHandler.document.writeln
strings to write to that other window - all this is output at the end of the 'normal' HTML output. It's nice since I can change the config so it can just use the same window that's open, or always open a new window if I rename it.

What I'm wondering now is if it would be possible to do something similar, except in the case that no window is open, a frameset opens up - the top frame would be a php script that modifies the configuration of the monitor thingie, so just opening a php or html file; and the cross-window scripting part (all these

windowHandler.document.writeln
lines) would go into the named target of this second frame.

In the case that this frameset popup was already open, the script would just write to that lower, named target frame, and wouldn't open up a whole new window.

I'm not asking for actual code (although it'd be welcome as a good example is always a great help), but to pointers - whether this is possible for someone who's no js genious, and how / where I could figure it out.

I guess that if it's not really possible, I'd just want to have the frameset always re-load both top and bottom frames.

Many thanks in advance.

Rambo Tribble

2:30 pm on Nov 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I'm interpreting you correctly, it sounds as if you want to add a frameset to an existing page. That might be a bit of a trick, unless the document was already defined as a frames document. It would probably be far easier to use an iframe which could be added through innerHTML or appendChild. The iframe could also be part of the original document but given a display:none or visibility:hidden CSS property.

mincklerstraat

4:59 pm on Nov 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Rambo Tribble, what I was thinking is opening a popup to a frameset if that window with the frameset wasn't already open, and in the case that it is already open, writing to one of the named target frames inside that frameset. Probably didn't express myself so clearly there.

Rambo Tribble

2:39 pm on Nov 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try this, see if it helps:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var targ='<iframe name="frmOne"><\/iframe>';
function mkWin(){
if(typeof winOne=="undefined" ¦¦ winOne.closed){
winOne=window.open("","oneWin","height=200px,width=300px,left=200px,top=200px");
}
}
</script>
</head>
<body onload="mkWin();">
<a href="#" onclick="alert(winOne.closed);winOne.focus();">check open or closed status of window</a>
<br /><br />
<a href="#"
onclick="winOne.document.body.innerHTML+=targ;winOne.focus();">add iframe to window</a>
<br /><br />
<a href="#" onclick="mkWin();winOne.focus();">make win manually (if closed)</a>
<br /><br />
<a href="your_file.htm" target="frmOne" onclick="winOne.focus();">targeted link</a>

</body>
</html>

mincklerstraat

3:22 pm on Nov 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Mr. Tribble:

very, very helpful indeed! Thanks so much. This is a great little example that'll get me where I need to go! Really hit the spot.