Well, the whole point of the script was for the content to overlap the link that initiated it, so any position changes you made were relative to the link. Anyhow, below is the modified version of the original Content Overlay script that centers the content on the page instead:
Code:
<script type="text/javascript">
/***********************************************
* Center of Page Content link- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body
}
function centerLay(box, type){
var firefox=document.getElementById&&!document.all
var posX=firefox? pageXOffset+window.innerWidth/2-box.offsetWidth/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-box.offsetWidth/2
var posY=firefox? pageYOffset+window.innerHeight/2-box.offsetHeight/2 : ietruebody().scrollTop+ietruebody().clientHeight/2-box.offsetHeight/2
if (type=="left")
return posX
else
return posY
}
function overlay(curobj, subobj){
if (document.getElementById){
var subobj=document.getElementById(subobj)
subobj.style.left=centerLay(subobj, "left")+"px"
subobj.style.top=centerLay(subobj, "top")+"px"
subobj.style.visibility="visible"
return false
}
else
return true
}
function overlayclose(subobj){
document.getElementById(subobj).style.visibility="hidden"
}
</script>
<body>
<b><a href="search.htm" onClick="return overlay(this, 'subcontent')">Search DD</a></b><br />
<!--Sub content to overlay link when clicked on. Do not remove outermost <div id="subcontent"> tag below. -->
<DIV id="subcontent" style="position:absolute; visibility: hidden; top: 0">
<div style="border: 9px solid orange; background-color: white; width: 300px; padding: 8px">
<p><b>Search Dynamic Drive:</b></p>
<form method="get" action="http://search.freefind.com/find.html" id="topform">
<input type="HIDDEN" NAME="id" SIZE="-1" VALUE="6299074" />
<input type="HIDDEN" NAME="pageid" SIZE="-1" VALUE="r" />
<input type="HIDDEN" NAME="mode" SIZE="-1" VALUE="ALL" />
<input type="HIDDEN" name="n" value="0">
<input name="query" maxlength="255" style="width: 150px" id="topsearchbox" alt="Search" />
<input value="Search" class="topformbutton" type="submit" />
</form>
<div align="right"><a href="#" onClick="overlayclose('subcontent'); return false">Close</a></div>
</div>
</DIV>
<p><b><a href="search.htm" onClick="return overlay(this, 'subcontent2')">Another example</a></b><br /></p>
<!--Sub content to overlay link when clicked on. Do not remove outermost <div id="subcontent2"> tag below. -->
<DIV id="subcontent2" style="position:absolute; visibility: hidden; top: 0">
<div style="border: 9px solid black; background-color: lightyellow; width: 400px; height: 400px; padding: 8px">
Some content. Some content.
<div align="right"><a href="#" onClick="overlayclose('subcontent2'); return false">Close</a></div>
</div>
</DIV>
The installation instructions for this script is exactly the same as the original script as far as what goes in the HEAD, in the BODY, and how to designate the overlay content.
Bookmarks