我的浏览器在这里有一些奇怪的经历.以下代码已上传到此网址:http://roberthanson.net/index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script src="scripts/jquery-1.6.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function($) {
$('ul li').click(function() {
$('input#shareto').val($(this).data('val'));
});
});?
</script>
</head>
<body>
<form>
<ul>
<li data-val="0-1">
<a href="#" title="" class="selected"><span class="to-admin">Administrator</span></a>
</li>
<li data-val="1-1">
<a href="#" title=""><span class="to-finance">Finance</span></a>
</li>
<li data-val="1-0">
<a href="#" title=""><span class="to-technician">Technician</span></a>
</li>
<li data-val="0-0">
<a href="#" title=""><span class="to-lawyer">Legal</span></a>
</li>
</ul>
<input id="shareto" type="text" value="1-0" name="shareto">
?
?</form>????????
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当我在Linux上使用Microsoft Internet Explorer和Firefox打开时,这些代码完美无缺.根据点击的LI标签更改值.但我不认为这种行为发生在我的Mac上.我的Mac上安装的所有浏览器(Safari,Chrome甚至Firefox本身)都没有提供与IE或Firefox相同的结果.
我是唯一一个有这种经历的人吗?或者我们是否有一些额外的代码使它适用于Mac?谢谢你.
好的,我尝试了你的代码,但它对我的Linux上的Chromium不起作用.
我得到的错误是Unexpected token ILLEGAL在第12行.
我复制粘贴你的代码到vim检查括号匹配和其他可能导致这些问题的东西.这样做,我在我的vim缓冲区中看到了这个:
`<200b>`
Run Code Online (Sandbox Code Playgroud)
当vim无法渲染角色时,vim会做什么.快速浏览维基百科可以看出,U + 200b是ZWSP,或者是零宽度空间.我不知道你的代码中是如何看到一个隐形字符,但似乎JavascriptCore,Webkit javascript引擎不喜欢那些字符,但是V8和SpiderMonkey(我认为?无论如何都是FF)都可以.
简而言之,修复是删除});脚本块末尾之后的不可见字符.您可以像删除任何角色一样执行此操作,您将看不到任何差异.
| 归档时间: |
|
| 查看次数: |
1742 次 |
| 最近记录: |