ZanoxWeb服务-上下文产品搜索小部件博客网站
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ZanoxWeb服务-上下文产品搜索小部件博客网站相关的知识,希望对你有一定的参考价值。
zanox Web Services - Contextual Product Search Widget for blogger.com
<ul id="zxAdList"></ul> function addScript(url) { var script = document.createElement('script'); script.src = url + '&t=' + new Date().getMinutes(); script.type = 'text/javascript'; document.getElementsByTagName('head')[0].appendChild(script); } function productSearch(version, applicationid, adspace, region, programs, minPrice, maxPrice, category, page, items, q, callback) { var url = 'http://api.zanox.com/json'; if (version) url+= '/' + version; url += '/products?applicationid=' + applicationid; if (adspace) url += '&adspace=' + adspace; if (region) url += '®ion=' + region; if (programs) url += '&programs=' + programs; if (category) url += '&category=' + category; if (page) url += '&page=' + page; if (items) url += '&items=' + items; if (minPrice) url += '&minPrice=' + minPrice; if (maxPrice) url += '&maxPrice=' + maxPrice; if (callback) url += '&callback=' + callback; if (q) url += '&q=' + q; addScript(url); } function renderLinkListItem(content, link, itemContainer) { var li = document.createElement("li"); itemContainer.appendChild(li); } function handler(data) { if (data.productsResult) { var productItems = data.productsResult.productItem; var zxAdList = document.getElementById('zxAdList'); //ID of a UL HTML element for (var i = 0; i < productItems.length; i++) { var productItem = productItems[i]; var link = ''; if (productItem.url.adspace instanceof Array) { // select tracking link related to the first Adspace link = productItem.url.adspace[0].$; } else { link = productItem.url.adspace.$; } var content = productItem.name + ' bei ' + productItem.program.$ + ' für ' + productItem.price + ' ' + productItem.currency; renderLinkListItem(content, link, zxAdList); } } } var zx_query = document.getElementsByTagName('h3').item(0).getElementsByTagName('a').item(0).innerHTML; //contextual product search parameters: version, applicationid, adspace, region, programs, minPrice, maxPrice, category, page, items, q, callback productSearch(null, 'BE94C4947839E8AB4D67', null, 'de', '660', null, null, null, 0, 5, zx_query, 'handler'); </script>
以上是关于ZanoxWeb服务-上下文产品搜索小部件博客网站的主要内容,如果未能解决你的问题,请参考以下文章