javascript快顯視窗中增加確定取消按鈕,javascript快顯視窗

來源:互聯網
上載者:User

javascript快顯視窗中增加確定取消按鈕,javascript快顯視窗

比例a標籤點擊後,彈出帶確定與取消的視窗,點擊確定則執行一個動作,否則不執行.

首先我們用ecshop 模板使用舉例

{if $votings eq 1}  <a href="javascript:;" onclick="if (confirm('多次投票將扣除100個積分,您確定投票嗎?')) {vote_this({$item.id},{$item.cat_id});}else{return false;}" id="supportme15" > </a> {else}  <a href="javascript:;" onclick="vote_this({$item.id},{$item.cat_id})" id="supportme15" > </a> {/if}<script type="text/javascript">function vote_this(voting_id,cat_id){ $.post("voting_ajax.php", {cat_id:cat_id,voting_id:voting_id}, function(data){ alert(data.message); window.location.reload(); },"json");}</script>

解釋.$votings用來判斷是否多次投票,如果再投票,則執行 js函數vote_this(),扣積分.

如果後台發現會員是初次投票.則直接執行,不需要扣積分,自然也不需要提醒了.

上面的方法可簡單的總結為

使用JS的Confirm彈出

例:用確認對話方塊使使用者做出決定

<script>  like=window.confirm("你覺得好嗎?");  if(like==true)    document.write("謝謝你的誇獎");//確定  else    document.write("希望得到你的誇獎");//取消</script>

是不是非常的簡單呢,希望本文能夠幫到大家

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.