DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> CSS入門知識 >> CSS詳解
八種寫法實作網頁「重新整理」按鈕
編輯:CSS詳解     

想在頁面上放一顆刷新鈕,寫法其實不只一種。以下整理八種常見做法,可依情境挑用。

常見寫法

<input type=button value=刷新 onclick="history.go(0)">
<input type=button value=刷新 onclick="location.reload()">
<input type=button value=刷新 onclick="location=location">
<input type=button value=刷新 onclick="location.assign(location)">
<input type=button value=刷新 onclick="location.replace(location)">

較少見的寫法

<input type=button value=刷新 onclick="document.execCommand('Refresh')">
<input type=button value=刷新 onclick="window.navigate(location)">
<input type=button value=刷新 onclick="window.open('自身的檔名','_self')">
<input type=button value=刷新 onClick=document.all.WebBrowser.ExecWB(22,1)>

實務上最通用的是 location.reload(),語意清楚且相容性最好;history.go(0) 效果相同,但語意偏向瀏覽紀錄操作。最後幾種帶有明顯的 IE 專屬色彩,跨瀏覽器時要多留意。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved