Results 1 to 3 of 3

Thread: gfeedfetcher inside a function not working in Firefos 19, Ubuntu

  1. #1
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default gfeedfetcher inside a function not working in Firefos 19, Ubuntu

    1) Script Title: gfeedfetcher.js

    2) Script URL (on DD): http://elot.ca/classify/newsfeed.php

    3) Describe problem: I have wrapped the script contents inside a function, it is activated with a button, It works in Google Chrome but not in Firefox 19.0
    <html>
    <head>
    <script type="text/javascript" src="http://www.google.com/jsapi">
    </script>
    <script type="text/javascript" src="gfeedfetcher.js">
    /***********************************************
    * gAjax RSS Feeds Displayer- (c) Dynamic Drive (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    </script>
    <script type="text/javascript">
    function loadfeeds()
    {
    var newsfeed=new gfeedfetcher("ample", "ampleclass", "_new")
    newsfeed.addFeed("BBC", "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml")
    newsfeed.displayoptions("label datetime snippet") //show the specified additional fields
    newsfeed.definetemplate("<div style ='width: 410px; height:120px; padding: 4px; border: 1px solid sienna; float:left;'>{title}<br /><div style= 'color:brown; font-size: 90%; float:left; padding-right: 4px;'>{label} </div><div style='color:gray; font-size: 90%; float:left;'> {date}</div><br />{description}</div>")
    newsfeed.setentrycontainer("p") //Display each entry as a p
    newsfeed.filterfeed(40, "date") //Show 40 entries, sort by date
    newsfeed.init() //Always call this last
    }
    </script>
    </head>
    <body>
    <button type="button" onclick = loadfeeds()>Load feeds</button>
    </body>
    </html>

  2. #2
    Join Date
    Aug 2004
    Posts
    9,890
    Thanks
    3
    Thanked 964 Times in 953 Posts
    Blog Entries
    15

    Default

    The first line:

    var newsfeed=new gfeedfetcher("ample", "ampleclass", "_new")

    must be loaded synchronously on the page, meaning it can't be put inside a function and called on demand. However, the subsequent lines inside the initialization code can. What you can do then is simply call the last line inside the initialization code on demand, when you wish the contents of the feed to actually be shown:

    Code:
    <html>
    <head>
    <script type="text/javascript" src="http://www.google.com/jsapi">
    </script>
    <script type="text/javascript" src="gfeedfetcher.js">
    /***********************************************
    * gAjax RSS Feeds Displayer- (c) Dynamic Drive (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    </script>
    <script type="text/javascript">
    function loadfeeds()
    {
    var newsfeed=new gfeedfetcher("ample", "ampleclass", "_new")
    newsfeed.addFeed("BBC", "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml")
    newsfeed.displayoptions("label datetime snippet") //show the specified additional fields
    newsfeed.definetemplate("<div style ='width: 410px; height:120px; padding: 4px; border: 1px solid sienna; float:left;'>{title}<br /><div style= 'color:brown; font-size: 90%; float:left; padding-right: 4px;'>{label} </div><div style='color:gray; font-size: 90%; float:left;'> {date}</div><br />{description}</div>")
    newsfeed.setentrycontainer("p") //Display each entry as a p
    newsfeed.filterfeed(40, "date") //Show 40 entries, sort by date
    }
    </script>
    </head>
    <body>
    <button type="button" onclick = "newsfeed.init()">Load feeds</button>
    </body>
    </html>
    DD Admin

  3. #3
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for that, you have saved me some head scratching.

Similar Threads

  1. php mail function in ubuntu
    By hemi519 in forum PHP
    Replies: 6
    Last Post: 11-22-2010, 07:48 PM
  2. setTimeout inside while loop does not function.
    By sniperman in forum JavaScript
    Replies: 3
    Last Post: 09-20-2009, 08:00 AM
  3. Replies: 9
    Last Post: 09-16-2008, 05:31 PM
  4. out side of function or inside of function
    By riptide in forum JavaScript
    Replies: 2
    Last Post: 07-12-2007, 04:10 PM
  5. Replies: 4
    Last Post: 06-17-2007, 08:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •