This article describes practical JS techniques. Share it for your reference, as follows:
js blocking error
Put the following code in a JS script
<script type="text/javascript">window.onerror = function(){ alert("Script error occurred"); return true;}alert(b);</script>Note: Defining the onerror event should be before an error occurs, otherwise a script error will occur.
How to prevent scroll bars from appearing when setting DIV?
style="overflow-x: hidden; overflow-y: auto;"
Controlling the style of pages through JS can also be expressed in the form of arrays
function init(){ //document.getElementById("ac").style.display = "none"; equivalent to the following document.getElementById("ac").style["display"] = "none";}window.onload = init;How to control the location of the background image?
Because background attribute positioning is not affected by the object's patching factor, numerical positioning can be used
The default value of the background-position property is: 0% 0%, from the upper left corner of the specified area
#wrapper{ position:relative; background:url(../res/main_bg.png) no-repeat; background-position: 0% 5%; _background-image:none; display:none;}For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm skills", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm skills", "Summary of JavaScript traversal algorithms and techniques", and "Summary of JavaScript mathematical operations usage"
I hope this article will be helpful to everyone's JavaScript programming.