小编Tru*_*ynh的帖子

localStorage事件侦听器不会在Chrome中为本地文件触发

我需要在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中有什么问题?我根据需要打开两个标签.

javascript jquery html5 google-chrome local-storage

10
推荐指数
1
解决办法
6892
查看次数

在表达式语言中调用方法

如何使用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上运行时导致错误.

jsp tomcat el

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

el ×1

google-chrome ×1

html5 ×1

javascript ×1

jquery ×1

jsp ×1

local-storage ×1

tomcat ×1