PDA

View Full Version : dock content help



vinny.benson
09-02-2009, 06:50 PM
i found a script that i want to use on my site, but i cant seem to get it working in a scrolling div box....
the content within the div is pulled from another page with an ajax code i found.
so i need to use it within that page.

here is the DockContent Script (http://www.dynamicdrive.com/dynamicindex17/dockcontent.htm)

can someone help me with this

thanks

vinny

thenajsays
09-02-2009, 09:02 PM
lets see the code youre currently using

vinny.benson
09-02-2009, 10:26 PM
this is the code on the users page:


<style type="text/css">

.dockclass{
position:relative;
}

</style>


<script type="text/javascript">

/***********************************************
* Dock Content script- Created by and Dynamicdrive.com
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full script
***********************************************/

var offsetfromedge=0 //offset from window edge when content is "docked". Change if desired.
var dockarray=new Array() //array to cache dockit instances
var dkclear=new Array() //array to cache corresponding clearinterval pointers

function dockit(el, duration){
this.source=document.all? document.all[el] : document.getElementById(el);
this.source.height=this.source.offsetHeight;
this.docheight=truebody().clientHeight;
this.duration=duration;
this.pagetop=0;
this.elementoffset=this.getOffsetY();
dockarray[dockarray.length]=this;
var pointer=eval(dockarray.length-1);
var dynexpress='dkclear['+pointer+']=setInterval("dockornot(dockarray['+pointer+'])",100);';
dynexpress=(this.duration>0)? dynexpress+'setTimeout("clearInterval(dkclear['+pointer+']); dockarray['+pointer+'].source.style.top=0", duration*1000)' : dynexpress;
eval(dynexpress);
}

dockit.prototype.getOffsetY=function(){
var totaloffset=parseInt(this.source.offsetTop);
var parentEl=this.source.offsetParent;
while (parentEl!=null){
totaloffset+=parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function dockornot(obj){
obj.pagetop=truebody().scrollTop;
if (obj.pagetop>obj.elementoffset) //detect upper offset
obj.source.style.top=obj.pagetop-obj.elementoffset+offsetfromedge+"px";
else if (obj.pagetop+obj.docheight<obj.elementoffset+parseInt(obj.source.height)) //lower offset
obj.source.style.top=obj.pagetop+obj.docheight-obj.source.height-obj.elementoffset-offsetfromedge+"px";
else
obj.source.style.top=0;
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

</script>



<div id="A" class="dockclass">A</div>
<div style="height:600px;"></div>

<div id="B" class="dockclass">B</div>
<div style="height:600px;"></div>

<div id="C" class="dockclass">C</div>
<div style="height:600px;"></div>

<div id="D" class="dockclass">D</div>
<div style="height:600px;"></div>




<script type="text/javascript">

var dock0=new dockit("A", 0);
var dock1=new dockit("B", 0);
var dock2=new dockit("C", 0);
var dock3=new dockit("D", 0);

</script>


and this is the ajax code that pulls the page into the div



<script type="text/javascript">
var xmlHttp5;

function countMail(src)
{
xmlHttp5=GetXmlHttp5Object();
if (xmlHttp5==null)
{
sendRequest('ErrorMessage', 'Javascript Error.<br>AJAX not Supported!', 'blip.wav');
return;
}
var url="users.php";
url=url+"?q="+src;
xmlHttp5.onreadystatechange=stateChanged5;
xmlHttp5.open("GET",url,true);
xmlHttp5.send(null);
}
function stateChanged5()
{
if (xmlHttp5.readyState==4)
{
document.getElementById("Users").innerHTML=xmlHttp5.responseText;
}
}
function GetXmlHttp5Object()
{
var xmlHttp5=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp5=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp5=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp5=new ActiveXObject("Microsoft.XMLHTTP");
}
}
setTimeout('Users("all")', 1000);
return xmlHttp5;
}
</script>
<div id="Users">
</div>