Click to See Complete Forum and Search --> : New window launched by form needs scrollability


GoldDog
03-23-2003, 01:21 AM
I'm just a lowly cut-and-paster. Any of you js-heads out there help me with this? I am launching a new window upon submittal of a form with the following script, and I want to make that window scrollable. How would I do it? I thought that I could add the comment "scrollable," to my form target attribute, but that seems to have no effect. Also, how can I get this new window to launch in the center of the screen instead of top left? Any suggestions are appreciated.

target="_new:width={250},
resizable,
scrollable,
height={350},
status"
onSubmit="return createTarget(this);">


function createTarget(form) {
_target = form.target;
_colon = _target.indexOf(":");
if(_colon != -1) {
form.target = _target.substring(0,_colon);
form.args = _target.substring(_colon+1);
} else if(typeof(form.args)=="undefined") {
form.args = "";
}
if(form.args.indexOf("{")!=-1) {
_args = form.args.split("{");
form.args = _args[0];
for(var i = 1; i < _args.length;i++) {
_args[i] = _args[i].split("}");
form.args += eval(_args[i][0]) + _args[i][1];
}
}
form.args = form.args.replace(/ /g,"");
_win = window.open('',form.target,form.args);
if(typeof(focus)=="function")
_win.focus();
return true;
}

GoldDog
03-23-2003, 11:06 AM
Thanks Dave, that worked. Now how would I get this new window to launch in the center of the screen instead of top-left?

GoldDog
03-23-2003, 12:36 PM
This worked:
target="_new:width={270},
resizable,
scrollbars,
left={screen.width/2-135}
top={screen.height/2-175}
height={350},
status"
onSubmit="return createTarget(this);">


Thanks Dave!

GoldDog
03-23-2003, 01:49 PM
Netscape 4.08 launches the window in the right position, but full-size instead of the dimensions I specified. How do I handle that?

Netscape 7 launched it in the right position but twice the height. In fact, it actually launched it as a blank window, then opened another full-size window with the right content.

I'm not even going to worry about 6.0 at this point, and Opera is out of the question.

Can I easily work some browser detection into this script, or am I better off just doing away with the javascript for Netsape?

GoldDog
03-23-2003, 07:58 PM
Dave, as I mentioned I am just a newbie at this. Where do I put these variables? Obviously not in the target attribute of the form, right? But then, where in the script should they go, and which elements in the script am I then removing?

Confused,
Carter

pyro
03-23-2003, 08:00 PM
This page may be of interest to you: http://www.infinitypages.com/research/centeredpopup.htm

GoldDog
03-23-2003, 08:14 PM
I've been working with this script now and I'm inclined to stick with it. Yours looks pretty simple, but I don't see how to pass form values to it.

Dave has been helping me out quite a bit and I'm inclined to ride this wave to the beach first, before trying a new one.

By the way, your demo page says it works in Opera 7, then on the next line it says it doesn't work in Opera 7. ??? 7.0 is a huge download for me on my dinky little dialup, so I'll pass on testing it myself until I'm back on DSL in a couple months.

pyro
03-23-2003, 09:22 PM
I just posted the link to show how I did it. Feel free to use Dave's method.

Thanks for pointing out my typo. I have now fixed it. It was suppose to be NN4.7 in the works section.

GoldDog
03-23-2003, 09:55 PM
I changed the target frame to "_new" because "_blank" caused IE to react the way NN7.0 did, by launching a blank window - properly sized and positioned - then launching the requested page in a new, full-sized window.

Now, with "_new" it works properly in both IE and NN4.8, but NN7.0 still reacts as described above.

GoldDog
03-24-2003, 09:55 AM
Works like a charm! Thanks for all the help Dave.