2011-06-22 19 views
0

我寫了下面的腳本來彈出使用href消息,但在點擊彈出的形式也越來越重的OK爲什麼發生這種情況爲什麼點擊OK web表單重置

我寫了什麼是如下

<a href="" style="text-decoration: none;" onclick="return confirm('A student need for Accommodated, Modified, or Alternate assessment is determined by the student ARD committee working in collabration with the LPAC and must be documneted in the student IEP ');"> 
           ?</a> 

OK點擊

enter image description here

之前點擊確定後

enter image description here

enter image description here

回答

5

這是奇怪的是,你使用confirm()一個信息彈出。有之間確定和取消沒有區別,所以你可以只使用alert(),你還需要返回false所以它實際上並沒有按照鏈接:

<a href="" onclick="confirm('Whatever'); return false;">?</a> 

您發佈的原始版本鏈接到當前頁面(和重新加載頁面與現在空的形式)

你也可以使用一個跨度:

<span onclick="confirm('Whatever');">?</span> 
+2

但警報不提供是/否選項,我認爲OP是希望利用。也許可以確認/否定預定的主意。 – thescientist

+0

@thescientist通過閱讀OP的問題,看看這個例子,我不認爲他在使用OK/Cancel。 – Fosco

+0

是的,如果我想有好的和取消我怎麼可以然後 – Dotnet

1

這是因爲在一個確認框,點擊OK就返回true,這將導致錨 「繼續」 w ^這是默認行爲,在這種情況下(沒有定義的href)將重新加載當前頁面。考慮使用不同的標籤,像< SPAN>

編輯:或如下文所述,嘗試在標籤內的函數調用後加入

return false; 

+0

我可以有一個簡要說明請如何使用跨度 – Dotnet

+1

跨度只是另一個HTML標記,這也是內聯,如< a >。只需用_span_替換_a_ – thescientist

相關問題