HighDots Forums  

Problem with the script

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Problem with the script in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jacek Maria Jackowski
 
Posts: n/a

Default Problem with the script - 08-13-2004 , 07:38 AM






Look at this menu http://ocanic.wsisiz.edu.pl/~jackowsj/zagle/menu.php
It works good at Mozilla and MS IE but in the OPERA 7.54 it's not working
and is not readable. This menu uses this script - look at this please and
tell me what do if I want it working under Opera web browser:

function lib_bwcheck(){ //Browsercheck (needed)
this.ver=navigator.appVersion
this.agent=navigator.userAgent
this.dom=document.getElementById?1:0
this.opera5=(navigator.userAgent.indexOf("Opera")> -1 && document.getElementById)?1:0
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
this.ie=this.ie4||this.ie5||this.ie6
this.mac=this.agent.indexOf("Mac")>-1
this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
return this
}
var bw=lib_bwcheck()

/*** parametry kt�e mona konfigurowa�***/

FoldNumber = 5 //liczba link� g�nych
var stayFolded = false //zamkni�ie/otwarcie submenu po klikni�iu na link g�ny false/true
foldImg = 0 //liczba potrzebnych obrazk� (jeli wpiszesz 0, usu�obrazki z foldera)
mainOffsetY = 0 //odst� w pionie pomi�zy linkami w pixelach

//Domylny obrazek.
//Pami�aj o zmianie nazwy pliku jeli zamierzasz uy�innego obrazka
//var unImg=new Image();
//unImg.src='images/foldoutmenu_arrow.gif'

//var exImg=new Image(); //zmienna obrazka
//exImg.src='images/foldoutmenu_arrow_open.gif' //obrazek otwartego submenu

// NOTE: if you change the position of divCont from absolute to relative, you can put the foldoutmenu in a table.
// HOWEVER it will no longer work in netscape 4. If you wish to support netscape 4, you have to use absolute positioning.

/*** Nie zmienia�kodu poniej tej linii ***/

// Jednostki miary wyorzystane do pozycjonowania warstw.
var px = bw.ns4||window.opera?"":"px";

if(navigator.userAgent.indexOf('Opera')>-1 && document.getElementById){ //Opera 5 resize fix.
scrX= innerWidth; scrY= innerHeight;
document.onmousemove= function(){
if(scrX<innerWidth-10 || scrY<innerHeight-10 || scrX>innerWidth+10 || scrY>innerHeight+10){
scrX = innerWidth;
scrY = innerHeight;
initFoldout();
}
};
}

//konstrukcja obiekt�
function makeMenu(obj,nest){
nest= (!nest)?"":'document.'+nest+'.';
this.el= bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):document.getEle mentById(obj);
this.css= bw.ns4?this.el:this.el.style;
this.ref= bw.ns4?this.el.document:document;
this.x= (bw.ns4||bw.opera5)?this.css.left:this.el.offsetLe ft;
this.y= (bw.ns4||bw.opera5)?this.css.top:this.el.offsetTop ;
this.h= (bw.ie||bw.ns6)?this.el.offsetHeight:bw.ns4?this.r ef.height:bw.opera5?this.css.pixelHeight:0;
this.vis= b_vis;
this.hideIt= b_hideIt;
this.showIt= b_showIt;
this.moveIt= b_moveIt;
return this
}
//metody obiekt�
function b_showIt(){this.css.visibility='visible'}
function b_hideIt(){this.css.visibility='hidden'}
function b_vis(){if(this.css.visibility=='hidden' || this.css.visibility=='HIDDEN' || this.css.visibility=='hide') return true;}
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x+px; this.css.top=this.y+px}

/************************************************** **********************************
Funkcja zwijajca i rozwijajaca submenu
************************************************** **********************************/
function menu(num){
if(bw.bw){
if (!stayFolded){
for (var i=0; i<oSub.length; i++){
if (i!=num){
oSub[i].hideIt()
}
}
for(var i=1; i<oTop.length; i++){
oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].h)
}
}
if (oSub[num].vis()){
oSub[num].showIt()
}else{
oSub[num].hideIt()
}
for(var i=1; i<oTop.length; i++){
if (!oSub[i-1].vis()) oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].h+oSub[i-1].h+mainOffsetY)
else oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].h+mainOffsetY)
}
}
}

/************************************************** *******************
Funkcja inicjujca - niczego nie modyfikowa�
************************************************** *******************/
function initFoldout(){
//sprawdzenie wersji Opery
bw.opera5 = (navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?true:false
if (bw.opera5) bw.ns6 = 0

oTop = new Array()
oSub = new Array()
//tworzenie i ukrywanie
for (var i=0; i<FoldNumber; i++){
oTop[i] = new makeMenu('divTop'+i,'divCont')
oSub[i] = new makeMenu('divSub'+i,'divCont.document.divTop'+i)
oSub[i].hideIt()
}

//pozycjonowanie
oTop[0].moveIt(0,0)
for (var i=1; i<oTop.length; i++){
oTop[i].moveIt(0, oTop[i-1].y+oTop[i-1].h+mainOffsetY)
}

//wywietlanie
oCont = new makeMenu('divCont')
oCont.showIt()
}

//adowanie
if(bw.bw) onload = initFoldout;


--
******** Jacek Maria Jackowski POWERED BY FEDORA CORE 2 ********
* mail: jackowsj (AT) ANTYSPAMwsisiz (DOT) edu.pl ; gg:935481 *
* Linux is like a wigwame. No gates, no windows and apache inside *
************************************************** *****************


Reply With Quote
  #2  
Old   
Jacek Maria Jackowski
 
Posts: n/a

Default Re: Problem with the script - 08-13-2004 , 07:58 AM






JavaScript console in Opera shows me that:
Event thread: onload
Error:
name: TypeError
message: Statement on line 57: Expression evaluated to null or undefined and is not convertible to Object: this.el
Backtrace:
Line 57 of linked script http://192.168.2.2/test/script/menu.js
this.css = bw.ns4 ? this.el : this.el.style;
Line 114 of linked script http://192.168.2.2/test/script/menu.js
oTop[i] = new makeMenu("divTop" + i, "divCont");
At unknown location
{event handler trampoline}
but I'm not js literate so I don't know what works wrong

--
******** Jacek Maria Jackowski POWERED BY FEDORA CORE 2 ********
* mail: jackowsj (AT) ANTYSPAMwsisiz (DOT) edu.pl ; gg:935481 *
* Linux is like a wigwame. No gates, no windows and apache inside *
************************************************** *****************


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.