Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pop up box ?

Status
Not open for further replies.

gokeeffe

Programmer
Jan 11, 2005
170
IE
Hi

The last page of my registration form has a terms and

conditions link, so that the user can view their terms and

conditions. How do you code it so that when clicked it

brings up a small pop up box with the T&C.

Not sure if i have the correct forum even.

Regards and thanks

Graham
 
You'll probably have better luck with the Javascript forumn. Try searching for "open window" or "popup".


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Code:
<a href="t&c.html" target="_blank" onclick="window.open(this.href,'blank','width=200,height=200,toolbar=0,menubar=0,resizable=0,location=0');">Terms and conditions</a>
 
Vragabond

It kind of works but it actually opens the a href as a big window first and then when you close that you can se the small window

What does this mean target="_blank"

and what are the other options for

menubar=0,resizable=0,location=0'

Tks
 
Ooops, do this:
Code:
<a href="t&c.html" target="_blank" onclick="window.open(this.href,'blank','width=200,height=200,toolbar=0,menubar=0,resizable=0,location=0'); return false;">Terms and conditions</a>
Target means it will open in a new window. This is for the users who don't have JavaScript. window.open is a javascript method for opening a custom window. menubar=0 means new window won't have the menu, resizable=0 means user won't be able to resize it and location=0 means there will be no address line in the new window. You can omit these or give them a value of 1 if you want them to appear. I added return false at the end of onclick event which will prevent the window from opening twice.
 
Thats cool Vragabond ,

just one last question how can i position the box on the screen, example if i want to center it.

Tks
 
Sorry one final question can you add scroll bars to the

pop up.

Tks again
 
Scrollbars should be there by default, you can force them by using scrollbars=1. As for positioning, IE supports left=xx and top=xx to position the window, but I think other browsers don't. You can add it however, as others will simply ignore the values if they don't support it. You put all these among other features separated by commas, as seen above.
 
gokeefe...

You can position the window either onload of t&c.html, or right after the window.open() call in the main page. If you want to position it from the t&c.html, add this:

Code:
<script language="javascript"><!--

function position() {
    var totWidth = screen.width;
    var totHeight = screen.height;

    var thisWidth = 200;
    var thisHeight = 200;

    var newLeft = (totWidth / 2) - (thisWidth / 2);
    var newTop = (totHeight / 2) - (thisHeight / 2);

    window.moveTo(newLeft, newTop);
}

--></script>

<body onload="position();">
.
.
.

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top