Results 1 to 3 of 3

Thread: RSS Feed Issue (Click in link will Open New Window)

  1. #1
    Join Date
    Oct 2017
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post RSS Feed Issue (Click in link will Open New Window)

    Hi there,
    I have an issue with current coding of RSS feed. I was able to get RSS feed from 3 news papers and I have setteled them in one page. but issue rises if I add that page to another page using <iframe> it doesnot open in full page, it just open within the page height. Now my question is it possible to open in full new window page when I will click a link from RSS Feed. This code below actully I took from Dynamic Drive RSS feed

    link for the webpage that I have issue with - http://www.irelandawamileague.com/Rsfeedtest2.html

    Code:
    <div id="IrishNews"></div>
         
        <div class="content"><script>
    (function(c){
    	var uniquename = 'IrishNews' // id of target div
    	var query = 'select * from rss(0,5) where url = "https://www.irishtimes.com/cmlink/news-1.1319192"'; // query as explained in original version
    	var numretries = 30; // increase this number (number of retries) if you're still having problems
    
    		//////// No Need To Edit Beyond Here Unless You Want To /////////
    
    	var counter = typeof c === 'number'? c : numretries;
    	var thisf = arguments.callee;
    	var head = document.getElementsByTagName('head')[0];
    	var s = document.createElement('script');
    	window["callback_" + uniquename + (--counter)] = function(r){
    		head.removeChild(s);
    		if(r && r.query && r.query.count === 0 && counter > 0){
    			return thisf(counter);
    		}
    		//r now contains the result of the YQL Query as a JSON
    		var feedmarkup = '<p>';
    		var feed = r.query.results.item // get feed as array of entries
    		for (var i=0; i<feed.length; i++){
    			feedmarkup += '<a href="' + feed[i].link + '">';
    			feedmarkup += feed[i].title + '</a><br />';
    			feedmarkup += feed[i].description + '</p>';
    		}
    		document.getElementById(uniquename).innerHTML = feedmarkup;
    	};
    	var baseurl = "https://query.yahooapis.com/v1/public/yql?q=";
    	s.src = baseurl + encodeURIComponent(query) + "&format=json&callback=callback_" + uniquename + counter;
    	head.append(s);
    })();
    </script> </div>
    I am also attaching a screenshot of that RSS Feed news.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Capture.jpg 
Views:	28 
Size:	20.3 KB 
ID:	6205  

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,372
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    This is actually "unofficial code" that I wrote, not Dynamic Drive code. But it's based upon code from Dynamic Drive and/or JavaScriptKit.

    First thing I'd suggest is notice this line:

    Code:
    feedmarkup += '<a href="' + feed[i].link + '">';
    That's what creates the main link for each feed's item. If you want them to open up in a new tab, change to:

    Code:
    feedmarkup += '<a href="' + feed[i].link + '" target="_new">';
    "_new" will establish a reusable window/tab for these links. If you want all of them to have their own window or tab, use "_blank".

    If it's more of an issue of links within the feed items, that is links other than the main feed link, that can be dealt with in another way. Let me know.

    The browser cache may have to be emptied and/or the page refreshed to see changes.



    Alternatively, you could add the lines as shown (highlighted):

    Code:
    document.getElementById(uniquename).innerHTML = feedmarkup;
    var feedlinks = document.getElementById(uniquename).getElementsByTagName('A'), a = -1;
    while(++a < feedlinks.length){
    	feedlinks[a].target = '_blank';
    }
    same caveat about _blank vs _new as in my previous idea. This one, however, will get all links in each feed item, not just the main item link.
    Last edited by jscheuer1; 10-04-2017 at 11:36 PM. Reason: combine similar posts
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Oct 2017
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi jscheuer1,
    Thanks very much. Only the one line of code on top sorted out the issue. Lets see, if its working fine after few updates on news.

    Thanks

Similar Threads

  1. Replies: 1
    Last Post: 09-20-2010, 07:44 PM
  2. Replies: 0
    Last Post: 04-20-2010, 01:31 PM
  3. Require click on ad to open link
    By ExclusiveRnB in forum HTML
    Replies: 1
    Last Post: 05-18-2008, 02:44 AM
  4. want to open a new window from XML feed
    By a_design_interactive in forum JavaScript
    Replies: 1
    Last Post: 07-16-2006, 09:29 AM
  5. How to click on Image Map and open New Window
    By logancat in forum JavaScript
    Replies: 2
    Last Post: 01-08-2006, 05:57 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
  •