Tweak javascript to make it work in Netscape 4.7
-
Tweak javascript to make it work in Netscape 4.7 : (initially stationary image to slide across horizontally, stop, then slide along a bit more.) works in ie6 (or did before anyway ;-) this might not be possible in Netscape 4.7? 01 <html> 02 <head> 03 04 <script type="text/javascript"> 05 <!-- 06 var currentPosition=30; 07 08 function slideImageIntoView() 09 10 { 11 currentPosition++; 12 myimage.style.left = currentPosition; if(currentPosition > 127) { setTimeout("slideImageOutOfView()",5000); } else { setTimeout("welcomeMsg()",1); } } function slideImageOutOfView() { currentPosition++; myimage.style.left = currentPosition; if(currentPosition > 219) { exit(1); } else { setTimeout("slideImageOutOfView()",1); } } //--> </script> <style type="text/css"> <!-- #myimage{position:absolute;top:12px;left:30px} --> </style> </head> <body onLoad="slideImageIntoView()"> <img id="myimage" src="someimage.gif" alt=""> <!-- error message in netscape 4.7: JavaScript Error: http://mydomain/thisfile.html, line 12: myimage is not defined. --> </body> </html>
-
Answer:
Hello Gan, Try the follwing: ----- <html> <head> <title>Sample</title> <script type="text/javascript"> <!-- var currentPosition = 30; function slideImageIntoView() { currentPosition += 5; positionLayer("layer1", 30, currentPosition); if (currentPosition < 127) { setTimeout("slideImageIntoView()", 60); } else { setTimeout("welcomeMsg()", 1); } } function slideImageOutOfView() { currentPosition -= 5; positionLayer("layer1", 30, currentPosition); if (currentPosition > -100) { setTimeout("slideImageOutOfView()", 60); } } function positionLayer(lrName, x, y) { if (document.all) { document.all[lrName].style.left = x + "px"; document.all[lrName].style.top = y + "px"; } else if (document.layers) { document.layers[lrName].left = x; document.layers[lrName].top = y; } else if (document.getElementById) { elem = document.getElementById(lrName); elem.style.left = x + "px"; elem.style.top = y + "px"; } } function welcomeMsg() { alert("Welcome"); slideImageOutOfView(); } //--> </script> </head> <body onLoad="slideImageIntoView()"> <div style="position: absolute; top: 12px; left: 30px" id="layer1"> <img src="at.gif" alt=""> </div> </body> </html> ----- The image will move down, display the "Welcome" message, then move up again and out of the browser area. While you might want to change the behavior, the important function here is "positionLayer". It's a general function to position a layer and you may want to reuse it for other JavaScripts as well. It tests the browser's object model to then go into separate lines for each. Above HTML has been tested with Netscape Navigator 4.7 [1]. In general, "document.layer" is used for Netscape 4x, "document.all" for Internet Explorer and the standard "document.getElementById" for newer versions of Internet Explorer, as well as the more recent Netscape versions. I hope it helps! Footnotes: [1] Netscape 4.7 can be found at: Browser Archive http://browsers.evolt.org/ Search strategy: (none)
gan-ga at Google Answers Visit the source
Related Q & A:
- How can I make Private Messages in Drupal 7 with user user pictures like in Facebook?Best solution by Drupal Answers
- How Does An Automatic 4 Wheeler work?Best solution by ehow.com
- Will Call of Duty 4 work on a Computer?Best solution by Yahoo! Answers
- Does GTA 4 PC work online?Best solution by Yahoo! Answers
- How to make 3D work on my projector?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.