How to make a Adblocker detector in Javascript?

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

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

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.