php 如何做彈框提醒

來源:互聯網
上載者:User
php 怎麼做彈框提醒
需要定時給訊息接收者一個彈框提醒,類似QQ郵箱接收到新郵件的那種彈框提醒

------解決方案--------------------
很好用:http://download.csdn.net/detail/dmtnewtons/4219436
------解決方案--------------------
js中不是setInterval()函數嗎?
------解決方案--------------------
不可以
sleep 暫停了當前程式的執行,並沒有關閉當前的 http 會話
這樣的話,每個使用者上來都要佔用一個 socket 串連。系統的資源很快就會耗盡了

值得注意的是,有很多人試圖用 ajax 去類比長串連。這是自欺欺人的作法
沒有任何資料顯示,作為 ajax 核心組件的 XMLHttpRequest 具有串連重用的能力
既然如此,你在伺服器端不就是白等了嗎


------解決方案--------------------
Ajax:
PHP code
#將你的提示資訊放都後端,用Ajax調用:var xmlHttp;var timer = null;var timerRunning = false;var url;    function createXMLHttpRequest() {        if(window.XMLHttpRequest) {            xmlHttp = new XMLHttpRequest();        } else if (window.ActiveXObject) {            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");        }    }    function statusStop (){        if(timerRunning){              clearTimeout(timer);        }        timerRunning = true;    }    /* ------------------- 間隔查詢 ------------------- */    function autoDeep(){        createXMLHttpRequest();        url = "map.php?refresh="+Math.random();        method = "GET";        xmlHttp.open(method,url,true);        xmlHttp.onreadystatechange = null;        xmlHttp.send(null);        timerRunning = false;        timer = setTimeout('autoDeep()',5000);    //設定時間,此時為5秒    }    function statusBegin(){        statusStop();        autoDeep();    }    statusBegin();
------解決方案--------------------
探討
怎麼控制只有這個負責人會彈框提醒,其他人不會彈出這個框呢?

------解決方案--------------------
幕後處理的時候就能識別該使用者,就一個使用者的話可以直接給他加個判斷,把幾個js函數直接給他推到前台,特別是用模板時更容易實現,應該沒啥問題
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.