我需要在localStorage更改时收到通知.此代码在Firefox 24中运行良好,但在Chrome 29(或30)或IE 10中不起作用.它也可以在实时服务器上运行,但在我使用本地文件(file:///)进行测试时却无效.
这是代码:
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#submit').click(function() {
console.log('Clicked');
if($('#username').val() != "")
localStorage.setItem('someItem', 'someValue');
});
$(window).bind('storage', function(e) {
alert('change');
});
});
</script>
</head>
<body>
<input type="text" id="username" name="username" value="" />
<a href="#" id="submit">Click me</a>
<p id="result"></p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这在Chrome中有什么问题?我根据需要打开两个标签.
如何使用EL(表达式语言)在JSP中调用方法?
例如:
<c:forEach var="item" items="${listStr}" begin="0" end="2" step="2">
<p>${item.indexOf("h")}</p>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)
这里,item是一个类型的对象java.lang.String.这会在Tomcat上运行时导致错误.