Is there a way to make this code only run when the page loads for the first time?
Can I achieve something similar to IsPostBack
in JavaScript?
IsPostBack
: Determines if the page is being rendered for the first time or due to a postback. More info here.
<script>
window.onload = function TimedCss()
{
setTimeout(myTimeout1, 0500)
setTimeout(myTimeout2, 1000)
setTimeout(myTimeout3, 1500)
setTimeout(myTimeout4, 2000)
setTimeout(myTimeout5, 2500)
setTimeout(myTimeout6, 3000)
}
}
function myTimeout1()
{
document.getElementById("LBLName").className = " animated fadeInLeft";
document.getElementById("LBLName").style.visibility = "visible";
}
function myTimeout2()
{
document.getElementById("LBLDescription").className = " animated rotateIn";
document.getElementById("LBLDescription").style.visibility = "visible";
}
function myTimeout3()
{
document.getElementById("P1").className = " animated zoomIn";
document.getElementById("P1").style.visibility = "visible";
}
function myTimeout4()
{
document.getElementById("TXTQuantity").className = " animated flipInY";
document.getElementById("TXTQuantity").style.visibility = "visible";
}
function myTimeout5()
{
document.getElementById("LBLPrice").className = " animated slideInLeft";
document.getElementById("LBLPrice").style.visibility = "visible";
}
function myTimeout6()
{
document.getElementById("BTNAddToCart").className += " animated fadeInUp";
document.getElementById("BTNAddToCart").style.visibility = "visible";
}
</script>
Edit - Solution:
<script>
window.onload = function TimedCSS()
{
var isPostBack=<%= IsPostBack ? "true" : "false" %>
if (!isPostBack)
{
setTimeout(myTimeout1, 0500)
setTimeout(myTimeout2, 1000)
setTimeout(myTimeout3, 1500)
setTimeout(myTimeout4, 2000)
setTimeout(myTimeout5, 2500)
setTimeout(myTimeout6, 3000)
}
function myTimeout1()
{
document.getElementById("LBLName").className = " animated fadeInLeft";
document.getElementById("LBLName").style.visibility = "visible";
}
function myTimeout2()
{
document.getElementById("LBLDescription").className = " animated rotateIn";
document.getElementById("LBLDescription").style.visibility = "visible";
}
function myTimeout3()
{
document.getElementById("P1").className = " animated zoomIn";
document.getElementById("P1").style.visibility = "visible";
}
function myTimeout4()
{
document.getElementById("TXTQuantity").className = " animated flipInY";
document.getElementById("TXTQuantity").style.visibility = "visible";
}
function myTimeout5()
{
document.getElementById("LBLPrice").className = " animated slideInLeft";
document.getElementById("LBLPrice").style.visibility = "visible";
}
function myTimeout6()
{
document.getElementById("BTNAddToCart").className += " animated fadeInUp";
document.getElementById("BTNAddToCart").style.visibility = "visible";
}
</script>