0
有人可以幫我輸入一個JavaScript延遲這個代碼。 我想讓這段代碼在2秒後打開。當你打開網址時。 其他網站負載正常。使用javascript延遲與document.write
<script type="text/javascript">
var avail=$z:value[article.availableinstock];
if ($z:value[article.availableinstock] < 1)
{
document.write('<div class="shop_not">');
document.write("In order!");
}
else if ($z:value[article.availableinstock] >=100)
{
document.write('<div class="shop_ok">');
document.write(" 100+ in stock");
}
else if ($z:value[article.availableinstock] >=50)
{
document.write('<div class="shop_ok">');
document.write(" 50+ in stock");
}
else if ($z:value[article.availableinstock] >=25)
{
document.write('<div class="shop_ok">');
document.write(" 25+ in stock");
}
else
{
document.write('<div class="shop_bob">');
document.write(+ avail.toFixed(0));
document.write(" in stock");
}
</script>
你爲什麼要等待2秒了嗎? –
http://stackoverflow.com/questions/802854/why-is-document-write-considered-a-bad-practice – KooiInc
使用前的原因。 2秒是,當我使用腳本時,文章列表非常慢,甚至只有值。 – Frank