Avatar billede etlekana Nybegynder
02. august 2001 - 10:08 Der er 4 kommentarer og
2 løsninger

Netscape og iexplore. Problemer med onmousedown=\"if(doccomplete) scroll(10);\"

Dette virker fint i iexplore
onmousedown=\"if(doccomplete) scroll(10);\"
skal det skrives anderledes for at virke i netscape? For der virker det altså ikke.
Der virker funktionen ikke.
Avatar billede nute Nybegynder
02. august 2001 - 10:13 #1
det vil kanskje hjelpe hvis du forklarer hvilket tag du vil aktivere denne eventhandler !!? er det en <td>, <a>, <table> eller noe annet ??
Avatar billede etlekana Nybegynder
02. august 2001 - 10:46 #2
<a> Men det er jo ligesom ligemeget hvad det er.
Avatar billede nute Nybegynder
02. august 2001 - 11:48 #3
denne her virker i IE5 og NS4.72

<a href=\"#\" onMouseDown=\"alert(\'HEY\');\">Klikk</a>

Det kan heller se ut som om din doccomplete variabel ikke er global ?!
Avatar billede jakoba Nybegynder
02. august 2001 - 12:06 #4
funktionen scroll(10) er forældet.

brug istedet:
      onmousedown=\"if(doccomplete) scrollBy(0,10);\" // 10 px længere ned
      onmousedown=\"if(doccomplete) scroll(0,-10);\"  // 10 px længere op
      onmousedown=\"if(doccomplete) scrollBy(10,0);\" // 10 px længere tilhøjre
      onmousedown=\"if(doccomplete) scroll(-10,0);\"  // 10 px længere tilvenstre
eller:
      onmousedown=\"if(doccomplete) scrollTo(45,100);\" // absolut x,y koordinat ( 45 tilhøjre fra venstrekant, 100 ned fra top )

I netscape vil engen scroll-kommando virke medmindre vinduet er sat scrollable (som man er nødt til for at få scrollbars).

mvh JakobA
Avatar billede jakoba Nybegynder
02. august 2001 - 12:07 #5
Ups. To steder har jeg glemt an ændre scroll(...) til scrollBy(...)
Avatar billede etlekana Nybegynder
02. august 2001 - 12:23 #6
Det skal så lige siges at det er et lag jeg arbejder med. Her er hele sourcen....

<html>
<html>
<head>
<script language=\"javascript\">
doccomplete = false;
var isIE4 = (document.all) ? 1 : 0;
var isNav4 = (document.layers) ? 1 : 0;
var isMac = (navigator.userAgent.indexOf(\"Mac\")>-1);
var isNav6 = false;
var ua = navigator.userAgent;

if(ua.indexOf(\'Netscape6\')>0){
    isNav6 = true;
}


if((!isIE4)&&(!isNav4&&!isNav6)){
    location.href = \'browserversion.htm\';
}

var iWidth;
var iHeight;
var midX;
var midY;
var loaded;
var X;
var Y;
var gTimer;
var arrActiveMenus = new Array();
var arrActiveLevels = new Array();
var arrPosX = new Array();
var arrPosY = new Array();
var arrWidth = new Array();
var arrHeight = new Array();
var arrMouseBeenOver = new Array();
var z = 0;
var zMax;
var doOnce = false;

// global elements found in the file globalElements.htm
var gEl = new Array();
gEl[gEl.length] = \'bodyBg|162|91|593|333\'

if(isNav4||isNav6){
    document.captureEvents(Event.MOUSEMOVE);
    window.captureEvents(Event.RESIZE);
    window.onresize = handleResize;
}
document.onmousemove = mousePos;

if(isIE4){
    window.onresize = init;
}

function handleResize(){
    location.reload();
    return false;
}

function mousePos(e){
    if(loaded){
        if(isNav4||isNav6){
            X = e.pageX;
            Y = e.pageY;
        }
        if(isIE4){
            X = event.clientX + document.body.scrollLeft;
            Y = event.clientY + document.body.scrollTop;
        }
//        self.status = \'X = \' + X + \', Y = \' + Y
    }
}

if(Array.prototype.push && ([0].push(true)==true)){
    Array.prototype.push = null;
}
if(!Array.prototype.push){
    function array_push(){
        for(i=0;i< arguments.length;i++){
            this[this.length] = arguments[i];
        }
        return this.length;
    }
    Array.prototype.push = array_push;
}

if(!Array.prototype.pop){
    function array_pop(){
        lastElem = this[this.length-1];
        this.length = Math.max(this.length-1,0);
        return lastElem;
    }
    Array.prototype.pop = array_pop;
}

function init(){
    loaded = true;

    if(isNav4||isNav6){
        iWidth = window.innerWidth;
        iHeight = window.innerHeight;
    }
    if(isIE4){
        iWidth = document.body.clientWidth;
        iHeight = document.body.clientHeight;
    }

    // ######################## //
    // hardcode the document width
    // ######################## //
    if(iWidth<=755){iWidth=755;}
    if(iHeight<=494){iHeight=494;}

    // position the global elements
    for(i=0;i<gEl.length;i++){
        a = gEl[i].split(\'|\');
        positionElement(a[0],parseInt(a[1]),parseInt(a[2]),parseInt(a[3]),parseInt(a[4]),z);
        if(!doOnce){
            z = z +1;
        }
    }

    positionElement(\'divContainer\',182,135,500,263,z+1);
    if(!doOnce){z = z+1;}

    positionElement(\'scrollbar\',720,135,16,292,z+1);
    if(!doOnce){
        z = z+1;
        zMax = z;
        scrollInit(\'divContainer\',\'divContent\');
        doOnce = true;
    }

    // start the timer
//    setTimeout(\'init();\',200);
}

function positionElement(obj,xPos,yPos,w,h,zPos){
    if(isIE4){
        myObj = document.all[obj].style;
    }
    if(isNav4){
        myObj = document.layers[obj];
    }
    if(isNav6){
        myObj = document.getElementById(obj).style;
    }

    // ################################### //
    // hardcode the document width and height
    // ################################### //
//    myObj.top = parseInt((iHeight - 494)/2 + 15 + yPos);
//    myObj.left = parseInt((iWidth - 755)/2 + 15 + xPos);
    myObj.top = parseInt((iHeight - 494)/2 + yPos);
    myObj.left = parseInt((iWidth - 755)/2 + xPos);
    myObj.width = w;
    myObj.height = h;
    myObj.overflow = \'hidden\';
    myObj.visibility = \'visible\';
    myObj.zIndex = zPos;
}
</script>

<script type=\"text/javascript\" language=\"JavaScript\">
//Default browsercheck, added to all scripts!
function checkBrowser(){
    this.ver=navigator.appVersion
    this.dom=document.getElementById?1:0
    this.ie5=(this.ver.indexOf(\"MSIE 5\")>-1 && this.dom)?1:0;
    this.ie4=(document.all && !this.dom)?1:0;
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
    this.ns4=(document.layers && !this.dom)?1:0;
    //added
    this.ie4mac=this.ie4 && navigator.userAgent.indexOf(\"Mac\")>-1
    this.ie5mac=this.ie5 && navigator.userAgent.indexOf(\"Mac\")>-1
    this.ie55=(this.ver.indexOf(\"MSIE 5.5\")>-1 && this.dom)?1:0;
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5 || this.ie5mac)
//    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) || ie4mac
    return this
}
bw=new checkBrowser()

/*****************

You set the width and height of the divs inside the style tag, you only have to
change the divCont, Remeber to set the clip the same as the width and height.
You can remove the divUp and divDown layers if you want.
This script should also work if you make the divCont position:relative.
Then you should be able to place this inside a table or something. Just remember
that Netscape crash very easily with relative positioned divs and tables.

Updated with a fix for error if moving over layer before pageload.

****************/


//If you want it to move faster you can set this lower:
var speed=50

//Sets variables to keep track of what\'s happening
var loop, timer

//Object constructor
function makeObj(obj,nest){
    nest=(!nest) ? \'\':\'document.\'+nest+\'.\'
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+\'document.\'+obj):0;
      this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+\'document.\'+obj):0;
    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
    this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
    this.up=goUp;this.down=goDown;this.goTop=gotoTop;
    this.moveIt=moveIt; this.x; this.y;
    this.obj = obj + \"Object\"
    eval(this.obj + \"=this\")
    return this
}

function moveIt(x,y){
    this.x=x;this.y=y
    this.css.left=this.x
    this.css.top=this.y
}

//Makes the object go up
function goDown(move){
    if(this.y>-this.scrollHeight+oCont.clipHeight){
        this.moveIt(0,this.y-move)
            if(loop) setTimeout(this.obj+\".down(\"+move+\")\",speed)
    }
}
//Makes the object go down
function goUp(move){
    if(this.y<0){
        this.moveIt(0,this.y-move)
        if(loop) setTimeout(this.obj+\".up(\"+move+\")\",speed)
    }
}

//Back to top of scroll, called from the bottom of the scroll.
function gotoTop(){
    this.moveIt(0,this.y+(this.scrollHeight-oCont.clipHeight)+10)
}

//Calls the scrolling functions. Also checks whether the page is loaded or not.
function scroll(speed){
    if(scrollLoaded){
        loop=true;
        if(speed==0){
            oScroll.goTop()
        }else{
            if(speed>0){
                oScroll.down(speed)
            }else{
                oScroll.up(speed)
            }
        }
    }
}

//Stops the scrolling (called on mouseout)
function noScroll(){
    loop=false
    if(timer) clearTimeout(timer)
}
//Makes the object
var scrollLoaded;
function scrollInit(container,scroller){
    oCont=new makeObj(container)
    oScroll=new makeObj(scroller,container)
    oScroll.moveIt(0,0)
//    oCont.css.visibility=\'visible\'
    scrollLoaded=true;
}
//Call the init on page load
//onload=scrollInit;
</script>

<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">
</head>
<body>

<div id=\"scrollbar\" class=\"myEl\">
<table width=\"15\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">
    <tr>
        <script language=\"javascript\">
        if(isMac){
            document.write(\'<td><a href=\"#\" onmouseover=\"if(doccomplete) scroll(-20);\" onmouseout=\"noScroll();\"><img src=\"scrollUp.gif\" width=\"15\" height=\"13\" border=\"0\"></a></td>\');
        }else{
            document.write(\'<td><a href=\"#\" onmousedown=\"if(doccomplete) scroll(-10);\" onmouseup=\"noScroll();\"><img src=\"scrollUp.gif\" width=\"15\" height=\"13\" border=\"0\"></a></td>\');
        }
        </script>
    </tr>
    <tr>
        <td><img src=\"scrollBg.gif\" tppabs=\"scrollBg.gif\" width=\"15\" height=\"237\" border=\"0\"></td>
    </tr>
    <tr>
        <script language=\"javascript\">
        if(isMac){
            document.write(\'<td><a href=\"#\" onmouseover=\"if(doccomplete) scroll(20);\" onmouseout=\"noScroll();\"><img src=\"scrollDown.gif\" width=\"15\" height=\"13\" border=\"0\"></a></td>\');
        }else{
            document.write(\'<td><a href=\"#\" onmousedown=\"if(doccomplete) scroll(10);\" onmouseup=\"noScroll();\"><img src=\"scrollDown.gif\" width=\"15\" height=\"13\" border=\"0\"></a></td>\');
        }
        </script>
    </tr>
</table>
</div>


<div id=\"divContainer\" class=\"myEl\" style=\"clip:rect(0 500 263 0);\">
    <div id=\"divContent\">
        <table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"500\">
            <tr>
                <!-- start Internt -->
                <td width=\"240\" valign=\"top\">
                TeTekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.Tekst.
                Tekst.
                Tekst.
                Tekst.
                Tekst.
                Tekst.
                Tekst.
                Tekst.
                Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>Tekst.Tekst.<BR>
                </td>
                <!-- end Externt -->
            </tr>
        </table>


       
        <p><a href=\"#\" onclick=\"scroll(0);\">[Op]</a></p>
    </div>
</div>

<div class=\"myEl\" id=\"bodyBg\">
<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"593\" bgcolor=\"#ffffff\">
    <tr>
        <td><img src=\"spacer.gif\" width=\"593\" height=\"333\" border=\"0\"></td>
    </tr>
</table>
</div>
<script language=\"javascript\">
    init();
</script>
<script language=\"javascript\">
document.onreadystatechange=fnStartInit;
function fnStartInit()
{
  if (document.readyState==\"complete\")
  {
      doccomplete = true;
  }
}
</script>
</body>
</html>


Virker fint i internet explore, men geder i ns.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester