Почему не кроссбраузерно?
Приветствую!
Пишу rss-читалку в виде расширения к FF, используя jQuery. Работает только в IE и Maxthon. В остальных браузерах просто пустая страница. В код включен плагин jFeed. Вот код: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/transitional.dtd"> <html> <head> <title>Sage</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> // Начало кода jFeed function JFeedItem() {}; JFeedItem.prototype = { title: '', link: '', description: '', updated: '', id: '' }; function JRss(xml) { this._parse(xml); }; JRss.prototype = { _parse: function(xml) { if(jQuery('rss', xml).length == 0) this.version = '1.0'; else this.version = jQuery('rss', xml).eq(0).attr('version'); var channel = jQuery('channel', xml).eq(0); this.title = jQuery(channel).find('title:first').text(); this.link = jQuery(channel).find('link:first').text(); this.description = jQuery(channel).find('description:first').text(); this.language = jQuery(channel).find('language:first').text(); this.updated = jQuery(channel).find('lastBuildDate:first').text(); this.items = new Array(); var feed = this; jQuery('item', xml).each( function() { var item = new JFeedItem(); item.title = jQuery(this).find('title').eq(0).text(); item.link = jQuery(this).find('link').eq(0).text(); item.description = jQuery(this).find('description').eq(0).text(); item.updated = jQuery(this).find('pubDate').eq(0).text(); item.id = jQuery(this).find('guid').eq(0).text(); feed.items.push(item); }); } }; jQuery.getFeed = function(options) { options = jQuery.extend({ url: null, data: null, success: null }, options); if(options.url) { $.ajax({ type: 'GET', url: options.url, data: options.data, dataType: 'xml', success: function(xml) { var feed = new JFeed(xml); if(jQuery.isFunction(options.success)) options.success(feed); } }); } }; function JFeed(xml) { if(xml) this.parse(xml); }; JFeed.prototype = { type: '', version: '', title: '', link: '', description: '', parse: function(xml) { if(jQuery('channel', xml).length == 1) { this.type = 'rss'; var feedClass = new JRss(xml); } else if(jQuery('feed', xml).length == 1) { this.type = 'atom'; var feedClass = new JAtom(xml); } if(feedClass) jQuery.extend(this, feedClass); } }; // Конец jFeed </script> </head> <body> <script type="text/javascript"> jQuery(function() { jQuery.getFeed({ url: 'http://xxx/rss.php', success: function(feed) { jQuery('#result').append('<h2>' + '<a href="' + feed.link + '">' + feed.title + '</a>' + '</h2>'); var html = ''; for(var i = 0; i < feed.items.length && i < 10; i++) { var item = feed.items[i]; html += '<h3>' + '<a href="' + item.link + '">' + item.title + '</a>' + '</h3>'; html += '<div class="updated">' + item.updated + '</div>'; html += '<div>' + item.description + '</div>'; } jQuery('#result').append(html); } }); }); </script> <div id="result" /> </body> </html> Другие расширения FF эту же ленту читают нормально. Подскажите, в чем проблема? |
Цитата:
nule, вы действительно ждёте, что кто-то будет разбираться в этой толпе кода за вас? |
Я думаю, для определения проблемы с кроссбраузерностью, достаточно пробежаться опытным взглядом по операторам. Досконально разбираться в коде не требуется, тем более что он рабочий (в узких рамках).
|
Цитата:
посмотрите, на каком лайне ошибка. .... вы бы ещё over 9000 линий кода выложили и сказали "не работает" |
Часовой пояс GMT +3, время: 20:19. |