PDA

View Full Version : Center Preview


zoobie
12-07-2002, 04:55 AM
I need this feedback preview centered...

From the page users_comments.html:

<input type="button" value="PREVIEW" class="but1" onclick="previewit();">

...which pops this preview window that needs centering:

function previewit() {
var win=window.open("users_comments.html","","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,height=350, width=575,top=131,left=110");
win.document.write('<html><head><title>Preview</title></head><body bgcolor="#000000"><font style="font:normal italic 18 tahoma;color:white">');
win.document.write('&ampnbsp;&ampnbsp;&ampnbsp' + document.mail.comments.value + '</body></html>');
}

Looking for something simple.

Thanks :D

chrismiceli
12-07-2002, 05:50 AM
try this
function previewit() {
var win=window.open("users_comments.html",""," toolbar=no,location=no,directories=no,status=no,me
nubar=no,scrollbars=yes,copyhistory=no,height=350,
width=575,top=131,left=110");
win.document.write('<html><head><title>Preview</title></head><body bgcolor="#000000"><font style="font:normal italic 18 tahoma;color:white">');
win.document.write('&ampnbsp;&ampnbsp;&ampnbsp' + document.mail.comments.value + '</body></html>');
width = screen.width
height = screen.height
win.moveTo(width, height);

}

zoobie
12-07-2002, 07:05 AM
Nope...It just tries to open a window in default postion even taking out top=131,left=110...then self-closes.

Thanks

PauletteB
12-07-2002, 05:21 PM
Maybe this...

<script>
function previewit() {
var w = 575;
var h = 350;
var X = (screen.availWidth - w) / 2;
var Y = (screen.availHeight - h) / 2;
var win= window.open ("","","scrollbars=yes,width="+w+",height="+h+",left="+X+",top="+Y+"");

win.document.write('<html><head><title>Preview</title></head><body bgcolor="#000000"><span style="font:italic 18px tahoma; color:white;"><p>&nbsp;&nbsp;&nbsp;'+document.mail.comments.value+'</p></span></body></html>');
win.document.close();
}
</script>

<form name="mail" target="win">
<textarea name="comments" rows="10" cols="30" wrap="wrap"></textarea>
<input type="button" value="PREVIEW" class="but1" onclick="previewit();">
</form>

chrismiceli
12-07-2002, 06:40 PM
i find it weird, when using the .moveTo method, it move the top left corner of the window to the coordinates, not the center of the window, which would put your popup to the right of the actual coordinates, even if you told it the exact middle of your screen, i tried this function to find this out.
function previewit() {
var win=window.open("users_comments.html",""," toolbar=no,location=no,directories=no,status=no,me
nubar=no,scrollbars=yes,copyhistory=no,height=350,
width=575,top=131,left=110");
h = screen.height / 2
w = screen.width / 2
win.moveTo(h, w);
}

zoobie
12-07-2002, 07:38 PM
Nice Paulette...Code works better than mine. Thanks :D

Chris...Can't get yours to work. Thanks :eek: