如果有任何未保存的信息,我会尝试在用户转到应用内的其他页面之前提醒用户。我按照several stackoverflows的建议使用 append.title(row[1]) but it does not work.
In the CSV File --------------Needs to be:
1234 PRESTON ROAD -------- 1234 Preston Road
1245 JACKSON STREET ------- 1245 Jackson Street
8547 RAINING COURT ------- 8547 Raining Court
with open('C:\\Users\\Jake\\Desktop\\My Files\\Python Files\\PermitData.csv', 'rb') as f:
reader = csv.reader(f)
next (reader)
data = list(reader)
PermitData = []
for row in data:
PermitData.append(row[0]),PermitData.append(row[1]),PermitData.append(row[2]),
PermitData.append(row[3]),PermitData.append(row[4]),PermitData.append(row[5]),
PermitData.append(row[6])
results = PermitData
for result in results:
print result
f.close()
但它只在我刷新页面时才起作用,而不是在我点击网站上另一个页面的链接时。我是否误解了如何使用beforeunload或我是否需要其他事件监听器?
的application.js
.beforeunload
forms.js
//= require forms.js
答案 0 :(得分:0)
beforeunload
事件的工作原理如下:
// Fires just before leaving/refreshing the page. Handler will
// be passed the event object and if a returnValue is set on the
// event, the browser will display a confirmation dialog with the
// returnValue message displayed.
window.addEventListener("beforeunload", function (evt) {
evt.returnValue = "Setting this to anything but an empty string, causes this to work!";
}, false);
有关示例,请参阅this Fiddle。