我正在开发一个eBay列表,其中我使用的是JavaScript驱动的Tabber。
我相信eBay会自动删除<body> <html>
等标签,这样做会剥离<body onload="init()">
并禁止使用".cookie", "cookie(, "replace(".IFRAME, META, or includes), cookies, or href."
不幸的是我的JavaScript(HTML和CSS)技能非常差,但如果有人能告诉我我可以将<body onload="init()">
重命名为什么,我会非常感激,所以它会起作用吗?
这是一个指向外观的链接 - http://sweetvision.co.uk/ebayimages/Camo/gilet.html
这是列表的样子 - http://www.ebay.co.uk/itm/330879734834?var=&ssPageName=STRK:MESELX:IT&_trksid=p3984.m1555.l2649
这是代码:
<script type="text/javascript">
var tabLinks = new Array();
var contentDivs = new Array();
function init() {
// Grab the tab links and content divs from the page
var tabListItems = document.getElementById('tabs').childNodes;
for (var i = 0; i < tabListItems.length; i++) {
if (tabListItems[i].nodeName == "LI") {
var tabLink = getFirstChildWithTagName(tabListItems[i], 'A');
var id = getHash(tabLink.getAttribute('href'));
tabLinks[id] = tabLink;
contentDivs[id] = document.getElementById(id);
}
}
// Assign onclick events to the tab links, and
// highlight the first tab
var i = 0;
for (var id in tabLinks) {
tabLinks[id].onclick = showTab;
tabLinks[id].onfocus = function () { this.blur() };
if (i == 0) tabLinks[id].className = 'selected';
i++;
}
// Hide all content divs except the first
var i = 0;
for (var id in contentDivs) {
if (i != 0) contentDivs[id].className = 'tabContent hide';
i++;
}
}
function showTab() {
var selectedId = getHash(this.getAttribute('href'));
// Highlight the selected tab, and dim all others.
// Also show the selected content div, and hide all others.
for (var id in contentDivs) {
if (id == selectedId) {
tabLinks[id].className = 'selected';
contentDivs[id].className = 'tabContent';
} else {
tabLinks[id].className = '';
contentDivs[id].className = 'tabContent hide';
}
}
// Stop the browser following the link
return false;
}
function getFirstChildWithTagName(element, tagName) {
for (var i = 0; i < element.childNodes.length; i++) {
if (element.childNodes[i].nodeName == tagName) return element.childNodes[i];
}
}
function getHash(url) {
var hashPos = url.lastIndexOf('#');
return url.substring(hashPos + 1);
}
</script>
<body onload="init()">
<div class="Tabber">
<ul id="tabs">
<li><a href="#important" class="selected">Important</a></li>
<li><a href="#delivery" class="">Delivery</a></li>
<li><a href="#returns" class="">Returns</a></li>
</ul>
</div>
</body>
提前感谢您的帮助!