Hey.
Whats the SIMPLEST way of making an HTML popup, while still being able to set the height and width of the frame?
Simple question I know, but......
Thanks in advance,
James
Printable View
Hey.
Whats the SIMPLEST way of making an HTML popup, while still being able to set the height and width of the frame?
Simple question I know, but......
Thanks in advance,
James
<A href="java script:window.open(page.html,'popWin','resizable=yes,scrollbars=yes,width=580,height=460,toolbar=yes ,location=yes'); ">open me</a>
nope, didnt work for me :|
James
Thanks anyways
"java script" is one word, (this board makes it into a seperate word to help prevent tampering wiv browser operations etc ;)
If you want to create many popup windows and using little code, you should use a function like this
========================================
<html>
<head>
<title>Popup 1</title>
<script language="JavaScript" type="text/javascript">
<!--
var NewWin = null;
function openNewWin(url) {
//========================= SETTABLE VALUES ==========================
var Pwid = 600; //width of popup window - set for best form display
var Phgt = '60%'; //height of popup window as pct of main window
var Pedge = 100; //space on side of popup window
//====================================================================
Pwid = (screen && screen.width>700) ? Pwid : 600;
Phgt = (screen) ? screen.availHeight*(parseInt(Phgt)*.01) : 400;
var Plft = (screen) ? screen.width - Pwid - Pedge : 20;
var Ptop = (screen) ? screen.availHeight/2 - Phgt/2 : 20;
NewWin = open(url,'NewWin','width='+Pwid+',height='+Phgt+',left='+Plft+',top='+Ptop+',scrollbars=yes,resizabl e=yes');
setTimeout('if(NewWin&&!NewWin.closed)NewWin.focus()',100); }
//-->
</script>
</head>
<body>
<p><input TYPE="button" name="Window3" value="DownLoad"
onclick="openNewWin('http://www.download.com')"> <input TYPE="button" name="Window2"
value="MSN" onclick="openNewWin('http://www.msn.com')"> <input TYPE="button"
name="Window1" value="Yahoo!" onclick="openNewWin('http://www.yahoo.com')"></p>
</body>
</html>
========================================
OR, if you want to set each popup window to different settings:
========================================
<html>
<head>
<title>Popup 2</title>
<script LANGUAGE="JavaScript">
<!-- Begin
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
// End -->
</script>
</head>
<body>
<a href="#"
onclick="NewWindow(http://www.yahoo.com,'yahoo','300','300','yes');return false;">Yahoo.com</a>
</body>
</html>
========================================
I would do these kind of pop-ups more like this:
That way people without javascript can view the page too.Code:<a href="http://www.yahoo.com/"
onclick="NewWindow(this.href,'yahoo','300','300','yes');return false;">Yahoo.com</a>
OK, thanks for all yer help :)
Thanks to all of ya,
James
hmm.....
All those bits of code didnt work... lol :|
I would have preferred to use this bit of code: <A href="java script:window.open(page.html,'popWin','resizable=yes,scrollbars=yes,width=580,height=460,toolbar=yes ,location=yes'); ">open me</a>
As it allows to remove the toolbars etc, but I couldnt get it to work.. just got an error (and yes, I did make Javascript one word).
I also found this code:
<script language="JavaScript">
function newWindow(mypage,myname,w,h,features) {
if(screen.width){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
}else{winl = 0;wint =0;}
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
}
</script>
<a href="JavaScript:newWindow('comments.htm','popup',202,280,'' )" title="Comments">
Which does work. How would I make this, if the other code doesnt work, to remove the toolbars, and make it non-resizeable. I have tried to do it, but cant :|
James
what error did you get on mine?
if all these didn't work then it is something you are doing as they all work.
I got the error 'comments' is not defined.... :|
And I know its me screwing the code up... it usually is :|:|:|:|:|
lol
Cheers,
James
comments?? tha thas nothgin to do with the code I gave you. it must be in the page you are calling or the page that is doing the calling. you have a form field that is called comments?
Ah. I got the thing to work (it was missing ' ' at either size of the comments.htm.... anyways
Whenever I click the link.. well, see for yourself:
www.darkflight.com/Planned
Click on comments...
The popup appears, but the page messes up too :|
Cheers,
James
add this to the end of it.
return false;
so actually it will look like this
<A href="javascript:window.open('comments.htm','popWin','resizable=no,scrollbars=no,width=220,height=28 0,toolbar=no,location=no'); return false;">
then you ned to work on comments.htm file as it is way to big for that small of a window.
all seams cool to me?
R U sure its not just your browser?
however, with comments.html Try to use this:
Code:<body bgcolor="#FFFFFF" topmargin="0" leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0">
<center><iframe src="/Planned/comments1.htm" width="100%" height="100%" frameborder="0" scrolling="auto" style="background-image: url(images/blurrsm.jpg)" title="Comments"></iframe></center>
</body>
But i dont get why u dont just make the popup go to comments1.htm