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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple DHTML Cromeless Window

Status
Not open for further replies.

mtorbin

Technical User
Nov 5, 2002
369
US
Hey all,

I'm trying to find some simple (as in NO shorthand code) code that illustrates how to create a simple popUp window such as the one on this site when you first arrive. Any advice? I know JS pretty well, but the shorthand stuff always throws me.

- MT
 
Use a DIV. Position it with CSS. Make it positionable with JavaScript.

An example:


Click the graphic I have at the top with my logo in it. You'll get a div that you can position, drag, and close.

If you view the source of the page, you can see the script and the css behind it.



Thomas D. Greer
 
Thanks Thomas! That's just what I'm looking for.

- MT
 
Thomas (or anyone for that matter), here is a script I tossed together for testing:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
#pleaseWait {
	position: absolute;
	top: 50px;
	left 50px;
	width: 400px;
	text-align: left;
	visibility: hidden;
	padding: 5px;
	left: 50px;
}
.pwText {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 14px;
	font-weight: 800;
	color: #000000;
}
.pwBox {
	background-color: #FFFF99;
	padding: 2px;
	height: 30px;
	width: 390px;
}
</style>

<script type="text/javascript">
<!--
function showBox() {
    document.getElementById("pleaseWait").style.visibility = "visible";
}

function hideBox() {
    document.getElementById("pleaseWait").style.visibility = "hidden";
}
//-->
</script>
</head>

<body>
<a href="javascript: showBox();">SHOW MESSAGE</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript: hideBox();">HIDE MESSAGE</a><br>

<div id="pleaseWait">
<table class="pwBox">
 <tr>
  <td><div class="pwText">PLEASE WAIT... PART NUMBER SEARCH PROCESSING</div></td>
 </tr>
</table>
</div>
</body>
</html>

My question is, how do I center the box on ANY screen? Mean, I want it to be 50px from the top and ([screen resolution] / 2)px from the left.

Thanks,

- MT
 
I tried this, but it isn't seeming to work:

Code:
function showMessage() {
	var width = (screen.width)/2;
	document.getElementById("pleaseWait").style.left = width;
    document.getElementById("pleaseWait").style.visibility = "visible";
}
 
OK, I got it to work on Windows machines, but not my Mac (either browser engine). Wonder why? Oh well, thanks.

- MT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top