我正在尝试在javascript中将事件hanldler附加到beforeunload
。这是我的代码:
$(window).on("beforeunload", function() {
$("#popupin1").load("new.html");
})
我收到警报但是没有发生加载div。是否可以通过这种方式在关闭页面(弹出页面)时调用函数?
答案 0 :(得分:0)
最后我得到了答案。在同样的代码中做了一些改变
AsyncRestTemplate asyncRestTemplate = new AsyncRestTemplate();
List<HttpMessageConverter<?>> messageConverters = asyncRestTemplate.getMessageConverters();
StringHttpMessageConverter stringMessageConverter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
AllEncompassingFormHttpMessageConverter allEncompassingConverter = new AllEncompassingFormHttpMessageConverter();
allEncompassingConverter.setCharset(Charset.forName("UTF-8"));
allEncompassingConverter.setMultipartCharset(Charset.forName("UTF-8"));
allEncompassingConverter.setPartConverters(Collections.singletonList(stringMessageConverter));
for (Iterator<HttpMessageConverter<?>> iterator = messageConverters.iterator(); iterator.hasNext(); ) {
HttpMessageConverter conv = iterator.next();
if (conv instanceof AllEncompassingFormHttpMessageConverter) {
iterator.remove();
}
}
messageConverters.add(allEncompassingConverter);
asyncRestTemplate.setMessageConverters(messageConverters);
还需要
window.opener