gpt4 book ai didi

javascript - 适用于 ie9 和 ff4 - 不适用于 ie7 或 ie 8?

转载 作者:行者123 更新时间:2023-11-29 18:32:58 24 4
gpt4 key购买 nike

我不久前写了这个脚本并对其进行了修改以使用 css sprites 来减少图像。在 ie9 和 ff4 中一切正常,但是,我注意到它不会在 ie7/ie8 中显示...这一定是 css 或 js 问题,但我当然看不到任何会阻止旧 ie 显示代码的东西。 ..

我已经将下面的全部内容包含在一个“测试”页面中,其中包含所有内容...如果有人能指出为什么这在 ie7 或 ie8 中不起作用,我将不胜感激!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<style type="text/css">
#social16 {height:16px;font-size:13px; color:#0066ff; font-weight:bold;}
#sb16 {margin: 0px; padding:0px; height:16px; display: inline;line-height:16px;}
#sb16 li {list-style-type:none;float:left;padding:0 5px 0 0;}
#sb16 li a {background:url(social.png);background-repeat:no-repeat;display: block;height: 16px;width:16px;}
#sb16 li a.item0 {background-position:0px 0px;}
#sb16 li a.item1 {background-position:-16px 0px;}
#sb16 li a.item2 {background-position:-32px 0px;}
#sb16 li a.item3 {background-position:-48px 0px;}
#sb16 li a.item4 {background-position:-64px 0px;}
#sb16 li a.item5 {background-position:-80px 0px;}
#sb16 li a.item6 {background-position:-96px 0px;}
</style>
</head>
<body>
<div id="social16"></div>
<script type="text/javascript">
(function(){

var sites = [
['Send to Facebook', 'http://www.facebook.com/sharer.php?u={url}&amp;t={title}'],
['Tweet This', 'http://twitter.com/share?text={title}&amp;url={url}'],
['Send to StumbleUpon', 'http://www.stumbleupon.com/submit?url={url}&amp;title={title}'],
['Digg This', 'http://digg.com/submit?phase=2&amp;url={url}&amp;title={title}'],
['Send to GoogleBuzz', 'http://www.google.com/buzz/post?message={title}&amp;url={url}'],
['Send to Reddit', 'http://reddit.com/submit?url={url}&amp;title={title}'],
['Email to Friends', 'mailto:?subject={title}&amp;body={url}'],
];

var url = encodeURIComponent(location.href),
url = url.replace( "#", "" ),
title = encodeURIComponent(document.title),
html = '<ul id="sb16"><li>Share this ... </li>';

for (var i = 0, len = sites.length; i < len; i++) {
var site = sites[i],
link = site[1].replace('{url}', url).replace('{title}', title);

html += '<li><a class="item' + i + '" href="#" title="' + site[0] + '" onclick="window.open(\'' + link + '\')"></a></li>';
}

html += '</ul>';

document.getElementById("social16").innerHTML=(html);

})();
</script>
</body>
</html>

最佳答案

sites 的最后一个元素后有一个逗号:

var sites = [
//...
['Email to Friends', 'mailto:?subject={title}&amp;body={url}'],
// -----------------------------------------------------------^
];

IE6 和 IE7 不喜欢这样。这通常在数组的末尾显示为 null,而您最终会得到一个您不期望的 null

关于javascript - 适用于 ie9 和 ff4 - 不适用于 ie7 或 ie 8?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6025881/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com