Re: [問題] 紀錄離開網頁的時間

看板Ajax作者 (夢想。追逐)時間14年前 (2011/03/16 21:25), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
謝謝各位的指點,我剛剛照各位的方法寫,在離開網頁時 用js呼叫日期 在寫入檔案 全部都是在前端執行 可是不知道為何,一直無法建立文字檔... 有好心人願意幫我看看問題出在哪裡嗎? 我已經沒頭緒了>"< <html> <script language="javascript"> function WriteToFile() { //寫檔的函式 if (confirm('您確定要離開此頁面嗎?')) { var objFSO = new ActiveXObject('Scripting.FileSystemObject'); var dateObj = new Date(); var temp =''; temp = temp + dateObj.getYear(); temp = temp + dateObj.getMonth(); temp = temp + dateObj.getDate(); temp = temp + dateObj.getHours(); temp = temp + dateObj.getMinutes(); temp = temp + dateObj.getSeconds(); var objStream=objFSO.OpenTextFile("test.txt",ForWriting,true,false); objStream.WriteLine(temp); objStream.Close(); } } </script> <head> </head> <body onbeforeunload="WriteToFile()"> //由這個函式判斷離開網頁 載入函式 </body> </html> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.25.187.129
文章代碼(AID): #1DWBfOZ8 (Ajax)
文章代碼(AID): #1DWBfOZ8 (Ajax)