Prihlasovacie meno: Heslo:
Registrácia nového užívateľa
Moderátor: toedder 
 Computers

Have computer questions, hints, or tips?

BBW's Tips on how to speed up page load the brainking site
Computers (BIG BAD WOLF, 2007-03-12 20:16:01)


Počet správ na stránke:

Čo je nové o dvd players?
Zoznam diskusných klubov
Nie je vám dovolené písať správy do tohto klubu. Minimálna úroveň členstva vyžadovaná na písanie v tomto klube je Brain pešiak.
Mód: Každý môže písať
Hľadať v príspevkoch:  

8. mája 2007, 18:59:58
diogenysos 
Subjekt: javascript and different browsers:
hello all programming- and web-design-experts here -
i just uploaded a site called

centro verde

and i put in two scripts for a navigation-bar and for changing images. tested it in different browsers and there are occuring some mysterious mistakes... . those simple scripts should work cross-platform, but in some browsers i cant use my navigation-bar and in some the image-change-funktion seems to have problems. (one of the pages with image-change-function is this one
anyone has got an idea? sunny thanks for looking - diogenes

9. júna 2007, 08:58:57
Übergeek 바둑이 
Subjekt: Re: javascript and different browsers:
diogenysos:

I just read your message. I tested with two browsers. MS IE 6 is not my favorite, but it had no problem handling any of the scripts. Seamonkey 1.1.1 had no problems either. I used Sea Moneky in two machines. One is a Windows XP machine. The other is a Debian Linux machine. Both worked just fine. Linux comes with a browser called Koqueror. I tested with Konqueror 3.3.2 and the drop down menu works fine. However, the image swap failed.

First, about the drop-down menus. What browsers are causing problems? The reason why I don't like drop-down menus so much is because Mozilla browsers (that means Netscape, Fire Fox and Sea Monkey) handle DIV tags differently from the Microsoft browsers. Usually these drop down menus work by hiding and unhiding a DIV, and manipulating the Z-index to bring it to the front. Some work by positioning the DIV outside the normal screen margins so that it is not visible inside the normal computer display. Most of these require some checking of the browser version and they will manipulate the DIV differently depending on what browser is being used. You will have to read each individual browser documentation, and search out there for other versions of the drop-down menu to see if somebody has found a more stable approach.

About the image swap, I have found that this type of link is rather unstable:

<a href="javascript:swap('bild02','../images/coronasplaya1.jpg')">

For some reason some browsers have a hard time with inline Javascript like that. It works well in my XP machine with all browsers. My Linux machine failed with Koqueror as the browser.

Your Javascript function is perfectly correct and I have used a similar one before with great success and no problems in any browser:

function swap( bildname, tauschbild ) {
document.images[ bildname ].src = tauschbild;
}

Try replacing the links by a link like the ones below.

<a onMouseOver="swap( 'bild02' , '../images/coronasplaya1.jpg ' ); return true">
<a onClick="swap( 'bild02' , '../images/coronasplaya1.jpg ' ); return true">

Rather than having the Javascript inline in the HREF field, these use a mouse event such as the mouse moving over the link, or clicking the link. This type of link works great for swapping images. You can complete the tag by adding a target, and swapping to a different image when the mouse moves out of the link.

<a href="my_target.html" onMouseOver="swap( 'bild02' , '../images/coronasplaya1.jpg ' ); return true" onMouseOut="swap( 'bild02' , '../images/some_image.jpg ' ); return true">

I hope this helps.

Dátum a čas
Priatelia on-line
Obľúbené kluby
Spoločenstvá
Tip dňa
Copyright © 2002 - 2024 Filip Rachůnek, všetky práva vyhradené.
Späť na vrchol