Please help - question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Wilson

    Please help - question

    Could someone help me with how to center or pocission this document to the
    center of the page?

    <body onload="ImageBo ok()">
    <script type="text/javascript">

    // 7 variables to control behavior
    var Book_Image_Widt h=240;
    var Book_Image_Heig ht=325;
    var Book_Border=tru e;
    var Book_Border_Col or="gray";
    var Book_Speed=15;
    var Book_NextPage_D elay=1500; //1 second=1000
    var Book_Vertical_T urn=0;

    // array to specify images and optional links. At least 4
    // If Link is not needed keep it ""

    Book_Image_Sour ces=new Array(
    "photo1.jpg","" ,
    "photo2.jpg","" ,
    "photo3.jpg","" ,
    "photo4.jpg ","" // NOTE No comma after last line
    );

    var B_LI,B_MI,B_RI, B_TI,B_Angle=0, B_CrImg=6,B_Max W,B_Direction=1 ;
    var B_MSz,B_Stppd=f alse;B_Pre_Img= new Array(Book_Imag e_Sources.lengt h);

    function ImageBook(){
    if(document.get ElementById){
    for(i=0;i<Book_ Image_Sources.l ength;i+=2){
    B_Pre_Img[i]=new Image();B_Pre_I mg[i].src=Book_Image _Sources[i]}
    Book_Div=docume nt.getElementBy Id("Book");
    B_LI=document.c reateElement("i mg");Book_Div.a ppendChild(B_LI );
    B_RI=document.c reateElement("i mg");Book_Div.a ppendChild(B_RI );
    B_MI=document.c reateElement("i mg");Book_Div.a ppendChild(B_MI );
    B_LI.style.posi tion=B_MI.style .position=B_RI. style.position= "absolute";
    B_LI.style.zInd ex=B_RI.style.z Index=0;B_MI.st yle.zIndex=1;
    B_LI.style.top= (Book_Vertical_ Turn?Book_Image _Height+1:0)+"p x";
    B_LI.style.left =0+"px";
    B_MI.style.top= 0+"px";
    B_MI.style.left =(Book_Vertical _Turn?0:Book_Im age_Width+1)+"p x";
    B_RI.style.top= 0+"px";
    B_RI.style.left =(Book_Vertical _Turn?0:Book_Im age_Width+1)+"p x";
    B_LI.style.heig ht=Book_Image_H eight+"px";
    B_MI.style.heig ht=Book_Image_H eight+"px";
    B_RI.style.heig ht=Book_Image_H eight+"px";
    B_LI.style.widt h=Book_Image_Wi dth+"px";
    B_MI.style.widt h=Book_Image_Wi dth+"px";
    B_RI.style.widt h=Book_Image_Wi dth+"px";
    if(Book_Border) {

    B_LI.style.bord erStyle=B_MI.st yle.borderStyle =B_RI.style.bor derStyle="solid "
    ;
    B_LI.style.bord erWidth=1+"px";
    B_MI.style.bord erWidth=1+"px";
    B_RI.style.bord erWidth=1+"px";

    B_LI.style.bord erColor=B_MI.st yle.borderColor =B_RI.style.bor derColor=Book_B o
    rder_Color}
    B_LI.src=B_Pre_ Img[0].src;
    B_LI.lnk=Book_I mage_Sources[1];
    B_MI.src=B_Pre_ Img[2].src;
    B_MI.lnk=Book_I mage_Sources[3];
    B_RI.src=B_Pre_ Img[4].src;
    B_RI.lnk=Book_I mage_Sources[5];
    B_LI.onclick=B_ MI.onclick=B_RI .onclick=B_LdLn k;
    //B_LI.onmouseove r=B_MI.onmouseo ver=B_RI.onmous eover=B_Stp;
    B_LI.onmouseout =B_MI.onmouseou t=B_RI.onmouseo ut=B_Rstrt;
    BookImages()}}

    function BookImages(){
    if(!B_Stppd){
    if(Book_Vertica l_Turn){
    B_MSz=Math.abs( Math.round(Math .cos(B_Angle)*B ook_Image_Heigh t));
    MidOffset=!B_Di rection?Book_Im age_Height+1:Bo ok_Image_Height-B_MSz;
    B_MI.style.top= MidOffset+"px";
    B_MI.style.heig ht=B_MSz+"px"}
    else{ B_MSz=Math.abs( Math.round(Math .cos(B_Angle)*B ook_Image_Width ));
    MidOffset=B_Dir ection?Book_Ima ge_Width+1:Book _Image_Width-B_MSz;
    B_MI.style.left =MidOffset+"px" ;
    B_MI.style.widt h=B_MSz+"px"}
    B_Angle+=Book_S peed/720*Math.PI;
    if(B_Angle>=Mat h.PI/2&&B_Direction) {
    B_Direction=0;
    if(B_CrImg==Boo k_Image_Sources .length)B_CrImg =0;
    B_MI.src=B_Pre_ Img[B_CrImg].src;
    B_MI.lnk=Book_I mage_Sources[B_CrImg+1];
    B_CrImg+=2}
    if(B_Angle>=Mat h.PI){
    B_Direction=1;
    B_TI=B_LI;
    B_LI=B_MI;
    B_MI=B_TI;
    if(Book_Vertica l_Turn)B_MI.sty le.top=0+"px";
    else B_MI.style.left =Book_Image_Wid th+1+"px";
    B_MI.src=B_RI.s rc;
    B_MI.lnk=B_RI.l nk;

    setTimeout("Boo k_Next_Delay()" ,Book_NextPage_ Delay)}
    else setTimeout("Boo kImages()",50)}
    else setTimeout("Boo kImages()",50)}

    function Book_Next_Delay (){
    if(B_CrImg==Boo k_Image_Sources .length)B_CrImg =0;
    B_RI.src=B_Pre_ Img[B_CrImg].src;
    B_RI.lnk=Book_I mage_Sources[B_CrImg+1];
    B_MI.style.zInd ex=2;
    B_LI.style.zInd ex=1;
    B_Angle=0;
    B_CrImg+=2;
    setTimeout("Boo kImages()",50)}

    function B_LdLnk(){if(th is.lnk)window.l ocation.href=th is.lnk}
    function
    B_Stp(){B_Stppd =true;this.styl e.cursor=this.l nk?"pointer":"d efault"}
    function B_Rstrt(){B_Stp pd=false}
    </script>
    <div id="Book" style="position :relative">
    <p align="left">
    <img src="placeholde r.gif" width="144" height="227">
    </div>
    </body>


  • mscir

    #2
    Re: Please help - question

    Brian Wilson wrote:
    [color=blue]
    > Could someone help me with how to center or pocission this document to the
    > center of the page?[/color]

    How about this approach, use clientWidth to center it? You could shorten
    this up, I wanted to see if it would work..

    var alignment="midd le"; //"left";
    var leftedge;

    if (alignment=="le ft") {
    B_LI.style.left =0+"px";
    B_MI.style.left =(Book_Vertical _Turn?0:Book_Im age_Width+1)+"p x";
    B_RI.style.left =(Book_Vertical _Turn?0:Book_Im age_Width+1)+"p x";
    }
    if (alignment=="mi ddle") {
    leftedge=(docum ent.body.client Width-(2*Book_Image_W idth))/2;
    B_LI.style.left =leftedge+"px";
    B_MI.style.left =(Book_Vertical _Turn?leftedge: leftedge+Book_I mage_Width+1)+" px";

    B_RI.style.left =(Book_Vertical _Turn?leftedge: leftedge+Book_I mage_Width+1)+" px";
    }

    // if(Book_Vertica l_Turn){
    ....
    B_MI.style.left =leftedge+MidOf fset+"px";

    //if(B_Angle>=Mat h.PI){
    ....
    B_MI.style.left =leftedge+Book_ Image_Width+1+" px";

    <div id="Book" style="position :relative">
    <img src="placeholde r.gif" width="144" height="227">
    </div>

    Comment

    Working...