Results 1 to 3 of 3

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

  1. #1
    Join Date
    Oct 2017
    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 -

    <div id="IrishNews"></div>
        <div class="content"><script>
    	var uniquename = 'IrishNews' // id of target div
    	var query = 'select * from rss(0,5) where url = ""'; // 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){
    		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 = "";
    	s.src = baseurl + encodeURIComponent(query) + "&format=json&callback=callback_" + uniquename + counter;
    </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:	134 
Size:	20.3 KB 
ID:	6205  

  2. #2
    Join Date
    Mar 2005
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries


    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:

    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:

    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):

    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
    Thanked 0 Times in 0 Posts


    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.


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


Posting Permissions

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