Script ausführen

jemand anders

Erfahrenes Mitglied
Hallo,

in meiner Test-Fiddle ist ein Script deaktiviert, weil es in der Fiddle nicht läuft; im Blog klappt das aber problemlos.
Im Blog wollte ich das Script variieren, so dass sich auf Tastendruck der Feed-Anbieter ändert. Das wird aber nicht richtig gemacht. Das Script wird zwar ausgeführt, und die Sätze werden auch selektiert, aber sie werden nicht angzeigt. Das sieht dann so aus:

Code:
<script charset="UTF-8" type="text/javascript" src="http://feedroll.com/rssviewer/feed2js.php?src=http%3A%2F%2Fsjlendman.blogspot.com%2Ffeeds%2Fposts%2Fdefault%2F&au=y&date=y&targ=y&utf=y&html=a">
feed2js_ck = true;

document.write('<div class="rss-box">');
document.write('<ul class="rss-items">');
document.write('<li class="rss-item"><a class="rss-item" href="http://sjlendman.blogspot.com/2016/09/russia-irresponsibly-blamed-for.html" target="_blank"> Russia Irresponsibly Blamed for Ukraine\'s Downing of MH17</a> <span class="rss-item-auth">()</span><br />');
document.write('<span class="rss-date">2016-09-28 09:27:00.002-07:00</span><br />');
document.write('<div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\"><b>Russia Irresponsibly Blamed for Ukraine’s Downing of MH17</b></span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">by Stephen Lendman</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">The whole world knows, or should, that neither Russia nor Donbass freedom fighters had anything to do with downing MH17 two years ago, killing all passengers and crew members aboard.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">The most obvious question goes unanswered. Cui bono? For sure not Russia nor freedom fighters, refusing to accept fascist rule. What strategic benefit could they possibly gain by downing a commercial airliner unrelated to ongoing conflict? None, of course.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">Clearly, Washington, NATO and Ukraine benefitted greatly, more grist for their illegal sanctions regime, another phony pretext to vilify Putin, risking eventual East/West confrontation - the unthinkable possibility, maybe likelihood, of eventual nuclear war.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">The so-called Dutch Safety Board was no impartial investigator - comprised of the Netherlands, Belgium, Australia, Malaysia and Ukraine, Russia conspicuously denied involvement. </span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">Its mandate all along was not to let clear evidence interfere with its Russia/Donbass freedom fighters-bashing intention.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">Instead of doing its job responsibly, it came up with an implausible scenario, wrongfully claiming a Buk surface-to-air missile not used by Russia for many years, part of Ukraine arsenal, was delivered by Moscow to Donbass freedom fighters ahead of MH17’s downing.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">Sounds like a bad film plot. The books were cooked, so-called evidence fabricated because nothing linked Russia or Donbass fighters to the incident.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">Russia’s Foreign Ministry minced no words, saying Dutch investigators let Ukraine suppress what happened, enabling it to concoct a phony scenario, concealing its own culpability in the process, likely complicit with Washington.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">Russia’s credible investigatory analysis was ignored, US-installed Ukrainian putschists made a full member of the Joint Investigation Team (JIT) inquiry, making it a laughing stock.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">According to Russia’s Foreign Ministry spokeswoman Maria Zakharova, “(t)o this day, the investigators continue to ignore the overwhelming evidence provided by the Russian side, despite the fact that Russia is the only side that submits accurate information and constantly discloses new data.”</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">“Russia is disappointed that the situation surrounding the investigation into the Boeing crash is not changing. The findings of the Dutch prosecutor\'s office confirm that the investigation is biased and politically motivated” - entirely without credibility.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">“To arbitrarily designate a guilty party and dream up the desired results has become the norm for” the West - absolving culpable parties, blaming innocent ones.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">Russian firm Almaz-Antley once produced the type Buk missile claimed to have downed MH17, long ago discontinued, replaced by more sophisticated models.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">It conducted extensive analysis into MH17’s downing, its findings proving the missile came from Ukrainian military-controlled territory, not Donbass as falsely claimed.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">In addition, damage to MH17’s fuselage didn’t match so-called evidence in the JIT report - including the angle of impact, showing the missile couldn’t have come from Donbass.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">JIT’s report was fabricated to wrongfully blame Russia and Donbass freedom fighters for a crime likely orchestrated in Washington, Ukraine committing it for its paymaster.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">The militantly anti-Russia <a href=\"http://www.nytimes.com/2016/09/29/world/asia/malaysia-air-flight-mh17-russia-ukraine-missile.html\"><span style=\"-webkit-font-kerning: none; color: #1255cc;\">New York Times</span></a> reported the fabricated JIT account as factual - without challenging its politically motivated conclusions.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">Despite no credible evidence linking Moscow to MH17’s downing, plenty pointing to Ukraine and likely Washington, its headline screamed “Russia Implicated in Shooting Down Malaysia Flight 17 Over Ukraine.”</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">Big Lies take on a life of their own, especially when media scoundrels repeat them ad nauseam - longstanding NYT practice.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">A personal note. Daily Times editions include so much deplorable misinformation and Big Lies, supporting monied and imperial interests, I could devote all my writing to exposing them, doing nothing else, and barely scratch the surface.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">I selectively challenge its lying machine, most of my spent on many other important national and geopolitical issues - vital to discuss.</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">Stephen Lendman lives in Chicago. He can be reached at lendmanstephen@sbcglobal.net. </span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">His new book as editor and contributor is titled \"Flashpoint in Ukraine: How the US Drive for Hegemony Risks WW III.\"</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">http://www.claritypress.com/LendmanIII.html</span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">Visit his blog site at sjlendman.blogspot.com. </span></div><div style=\"font-family: Times; font-size: 12px; line-height: normal; min-height: 14px;\"><span style=\"font-kerning: none;\"></span><br /></div><br /><div style=\"font-family: Arial; font-size: 18px; line-height: normal;\"><span style=\"font-kerning: none;\">Listen to cutting-edge discussions with distinguished guests on the Progressive Radio News Hour on the Progressive Radio Network.</span></div>');
document.write('</li>');
...
...
...
document.write('<li class="rss-item"><a class="rss-item" href="http://sjlendman.blogspot.com/2016/09/the-nyt-lying-machine-in-action.html" target="_blank"> The NYT Lying Machine in Action</a> <span class="rss-item-auth">()</span><br />');
document.write('<span class="rss-date">2016-09-24 05:15:00.002-07:00</span><br />');
document.write('<div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\"><b>The NYT Lying Machine in Action</b></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\">by Stephen Lendman</div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\">If ignorance is bliss, it’s achievable by following deplorable Times reports - journalism (sic) at its worst, including some of the most despicable misreporting on Obama’s war against Syria, naked aggression it won’t explain.</div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\">The Syrian Arab Republic was invaded, America and its rogue allies using terrorists as imperial foot soldiers. Throughout years of conflict, Assad responsibly defended his people and nation - no easy task against hegemonic ruthlessness.</div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\">After observing Geneva ceasefire terms throughout a seven-day regime of silence, despite continued attacks on its forces and civilian population, Assad responded responsibly, Syria’s military attacking US-supported terrorists masquerading as moderates.</div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\"><span style=\"-webkit-font-kerning: none; color: #1255cc; font-family: Arial; font-size: 18px; line-height: normal; text-decoration: underline;\"><a href=\"http://www.nytimes.com/2016/09/24/world/middleeast/aleppo-syria-airstrikes.html?_r=0\">Times misreporting</a></span> followed, blaming Syria for combating terrorists massacring its people, saying resumption of bombing “opposition-held areas” in eastern Aleppo “knocked out running water to an estimated two million people.”</div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\">How possible in one portion of Aleppo, the entire city with a small fraction of its pre-war 2.3 million population?</div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\">The Times quoted James Le Mesurier, disgracefully calling Aleppo bombing “Dresden-esque” - an entire city US and UK forces mercilessly fire-bombed during WW II, turning 100,000 or more German civilians and wounded soldiers into molten flesh, despite the city having no military importance. </div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\">Mesurier co-heads the Soros supported White Helmet terrorist group, deceptively calling themselves volunteer rescue workers, “Mayday Rescue,” according to Times misreporting.</div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\">Ahead of resuming its battle for Aleppo, Syria’s military announced “the start of operations in eastern districts of the city and call(ed) on residents to stay away from the positions of terrorist groups.”</div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\">Once Syria’s largest city and commercial hub, much of it lies in ruins, a testimony to US imperial viciousness. </div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\">Times reports never explain, perpetuating the fiction of civil war, along with claiming nonexistent “moderate rebels” - disgracefully blaming Syrian and Russian forces for US-supported terrorists’ high crimes.</div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\">Stephen Lendman lives in Chicago. He can be reached at lendmanstephen@sbcglobal.net. </div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\">His new book as editor and contributor is titled \"Flashpoint in Ukraine: How the US Drive for Hegemony Risks WW III.\"</div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\">http://www.claritypress.com/LendmanIII.html</div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\">Visit his blog site at sjlendman.blogspot.com. </div><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal; min-height: 22px;\"><br /></div><br /><div style=\"font-family: Helvetica; font-size: 18px; line-height: normal;\">Listen to cutting-edge discussions with distinguished guests on the Progressive Radio News Hour on the Progressive Radio Network.</div>');
document.write('</li>');
document.write('</ul></div></center>');
</script>
Wie gesagt, die Sätze sind da, aber erscheinen nicht. Hat jemand eine Ahnung, was ich ändern muss?

Grüße
 
Zuletzt bearbeitet:
Ich habe nun versucht, das Script mit document.write einzubinden. Das wird zwar gemacht, aber dafür kommt danach nichts mehr. Außerdem erscheint ein Hinweis:
Mit document.write() wurde ein nicht balancierter Baum geschrieben, was dazu geführt hat, dass Daten aus dem Netzwerk neu geparst werden mussten. Für weitere Informationen https://developer.mozilla.org/en/Optimizing_Your_Pages_for_Speculative_Parsing
Ich schon mal nachgeschaut bei Mozilla, sehe aber nicht, was an dem Script falsch ist. Sieht einer den Fehler?
Code:
<script>
  document.write('<script language="JavaScript" src="http://feedroll.com/rssviewer/feed2js.php?src=http%3A%2F%2Fsjlendman.blogspot.com%2Ffeeds%2Fposts%2Fdefault%2F&num=3&au=y&date=y&targ=y&utf=y&pc=y&html=a"  charset="UTF-8" type="text/javascript"/>');
</script>
 
Interessantes Problem. Ein Blick in die Console zeigt, warum das Fiddle nicht läuft:
(index):55 Mixed Content: The page at 'https://jsfiddle.net/6c0wdc1q/' was loaded over HTTPS, but requested an insecure script 'http://feedroll.com/rssviewer/feed2js.php?src=http://sjlendman.blogspot.com/feeds/posts/default/&au=y&date=y&targ=y&utf=y&html=a'. This request has been blocked; the content must be served over HTTPS.

Ich habe mal eine Testseite aufgebaut und versucht, dein Skript dynamisch zu laden:
Code:
<!DOCTYPE HTML>
<html>
    <head>
        <title></title>
        <meta name="author" content="Claus">
        <meta name="editor" content="html-editor phase 5">
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
    </head>
    <body>
        <button id="load">Click to load</button>
        <div id="container"></div>
        <script>
            document.getElementById("load").addEventListener("click", function () {
                var container = document.getElementById("container");
                var script= document.createElement('script');
                script.id = 'scr';
                script.src= 'http://feedroll.com/rssviewer/feed2js.php?src=http%3A%2F%2Fsjlendman.blogspot.com%2Ffeeds%2Fposts%2Fdefault%2F&au=y&date=y&targ=y&utf=y&html=a';
                container.appendChild(script);
                //var box = document.getElementsByClassName("rss-box")[0];
                //if (box) box.parentNode.removeChild(box);
            });
        </script>
    </body>
</html>
Leider funktioniert es so nicht, Console sagt:
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
Erklärt wird der Sachverhalt hier:
http://stackoverflow.com/questions/...ible-to-write-into-a-document-from-an-asynchr
D. h. es funktioniert nicht, weil dieses Skript document.write verwendet. Mal wieder ein Grund mehr, document.write nicht zu verwenden.
Das Skript Postscribe, das bei stackoverflow empfohlen wird, funktioniert einwandfrei:
Code:
<!DOCTYPE HTML>
<html>
    <head>
        <title></title>
        <meta name="author" content="Claus">
        <meta name="editor" content="html-editor phase 5">
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/postscribe/2.0.6/postscribe.min.js"></script>
    </head>
    <body>
        <button id="load">Click to load</button>
        <div id="container"></div>
        <script>
            document.getElementById("load").addEventListener("click", function () {
                postscribe('#container', '<script src="http://feedroll.com/rssviewer/feed2js.php?src=http%3A%2F%2Fsjlendman.blogspot.com%2Ffeeds%2Fposts%2Fdefault%2F&au=y&date=y&targ=y&utf=y&html=a"><\/script>')
                //var box = document.getElementsByClassName("rss-box")[0];
                //if (box) box.parentNode.removeChild(box);
            });
        </script>
    </body>
</html>
So wie es jetzt ist, wird bei jedem Drücken des Knopfes das HTML im Containter hinzu gefügt, d. h. es tritt mehrfach auf. Wenn Du einen anderen Feed laden willst, musst Du zuvor die alten DOM-Elemente löschen, wie ich es schon angedeutet habe.
 
Zuletzt bearbeitet:
So, ich brauchte erst mal eine Mütze Schlaf, mir haben sich schon die Augen gedreht.

Jetzt habe ich die Sache mal getestet. Klappt wunderbar, das Script wird in am Ende eingefügt und dann folgen die Daten. Wenn ich sie lösche vor dem nächsten Aufruf, habe ich genau das, was ich wollte.

Aber warum sollte man zum Löchen man
Code:
var box = document.getElementsByClassName("rss-box")[0];
if (box) box.parentNode.removeChild(box);
verwenden; da wird das Script nicht mitgelöscht.
Mit
Javascript:
document.getElementById("container").innerHTML = "";
wäre der div komplett leer.

Da ich auf das PHP-Script keinen Einfluss habe, ist postScribe auf jeden Fall eine, wenn nicht sogar die einzige die Alternative!
Thx!!
 
Zuletzt bearbeitet:
Noch eine kleiner Nachtrag wegen einer Macke, die mir gerade auffällt. Mein Test-Script sieht momentan so aus:
HTML:
<!DOCTYPE HTML>
<html>
    <head>
        <title></title>
        <meta name="author" content="Claus">
        <meta name="editor" content="html-editor phase 5">
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/postscribe/2.0.6/postscribe.min.js"></script>
    </head>
    <body>
        <!-- direkt laden -->
        <div id="c1">
          <script language="JavaScript" src="http://feedroll.com/rssviewer/feed2js.php?src=https%3A%2F%2Fsjlendman.blogspot.com%2Ffeeds%2Fposts%2Fdefault&chan=y&tz=-1&utf=y&html=a"  charset="UTF-8" type="text/javascript"/><\/script>
        </div>

        <button id="load">Click to load</button>
        <div id="c2"></div>
        <script>
            document.getElementById("load").addEventListener("click", function () {
                if (document.getElementById("c2")) {
                  document.getElementById("c2").innerHTML = "";
                }
                //var box = document.getElementsByClassName("rss-box")[0];
                //if (box) box.parentNode.removeChild(box);
                postscribe('#c2', '<script language="JavaScript" src="http://feedroll.com/rssviewer/feed2js.php?src=https%3A%2F%2Fsjlendman.blogspot.com%2Ffeeds%2Fposts%2Fdefault&chan=y&tz=-1&utf=y&html=a"  charset="UTF-8" type="text/javascript"/><\/script>')
            });
        </script>
    </body>
</html>

Folgende Probleme treten nun auf:

Wird der Feed direkt über das Script geholt, d. h. ohne den Button zu benutzen, erscheint alles danach nicht mehr, d. h. ab dem Button.

Lässt man das Direktladen weg, ist der Button da, und der Feed wird auch geladen auf Klick.

Eine Besonderheit tritt dann allerdings beim Firefox auf, wenn man mit dem Button nachlädt. Ab einer bestimmen Menge von Sätzen kommt Firefox irgendwie durcheinander. Bei mir wird der Feed-Artikel "US Supports Terrorists in Syria, Says Al-Nusra Unit Commander" dann nicht mehr als List-Item - leicht eingerückt und mit dickem Punkt davor - dargestellt. Im DOM erscheinen dann plötzlich li-items (class=rss-item) parallel zu dem div (class=rss-box) statt unter ul (class=rss-items).
In Chrome klappt es dagegen fehlerfrei.

Schränkt man die Satzmenge auf ca. 10 Sätze ein (Parameter: &num=10), funktioniert Firefox ohne Probleme, wenn man die Satzmenge weglässt und alles, was da ist, geholt wird, treten offenbar Probleme auf.
 
Zuletzt bearbeitet:
Mit
Code (Javascript):
  1. document.getElementById("container").innerHTML = "";
wäre der div komplett leer.
Da hast Du Recht. Mein Vorschlag entstand dadurch, dass ich zunächst dachte, es sei ausreichend, einfach das src-Attribut im script-Tag auszutauschen.

Wird der Feed direkt über das Script geholt, d. h. ohne den Button zu benutzen, erscheint alles danach nicht mehr, d. h. ab dem Button.
Funktioniert bei mir einwandfrei. Beim Laden der Seite wird der Feed angezeigt und beim Drücken des Buttons ein zweites Mal. Allerdings musste ich ein paar Syntaxfehler beheben:
language="Javascript" ist veraltet und sollte gelöscht werden.
type="text/javascript"/><\/script>: Die fett markierten Striche sind fehlerhaft.
So ist es richtig:
Code:
<script src="http://feedroll.com/rssviewer/feed2js.php?src=https%3A%2F%2Fsjlendman.blogspot.com%2Ffeeds%2Fposts%2Fdefault&chan=y&tz=-1&utf=y&html=a"  charset="UTF-8" type="text/javascript"></script>

Leider läuft bei mir Firefox nicht, daher kann ich dich bei dem betr. Problem nicht unterstützen. Ich benutze Opera und habe zum Test noch Chrome und IE11 installiert.
 
Zuletzt bearbeitet:
Ich habe übrigens inzwischen die Fehler gefunden:

1. ein Media-Tag im Anchor-Tag an einer falschen Stelle bzw. generell falsch
HTML:
document.write('<li class="rss-item"><a class="rss-item" href="http://www.youtube.com/watch?v=Z6umCZYnv_A" target="_self"> Trauerkundgebung für die Meinungsfreiheit. Hamed Abdel Samt AfD trauertTrauerkundgebung für die Meinungsfreiheit. Hamed Abdel Samt AfD trauert<media:title /></a><br />');
2. fehlender Autor führt zu Leerzeilen, die als Fehler interpretiert werden
Javascript:
document.write('<li class="rss-item"><a class="rss-item" href="http://www.youtube.com/watch?v=qWJkhuaHTm0" target="_self"> Frauke Petry. Germany Protesters interrupt AfD event in RiedenFrauke Petry. Germany Protesters interrupt AfD event in Rieden<media:title /></a> <span class="rss-item-auth">(
 
 
  )</span><br />');
 
Zuletzt bearbeitet:
Ist das aus dem Skript, das Du dort einziehst? Wenn ja, ist es ja wahrscheinlich schwierig, weil Du darauf keinen Einfluss hast. Oder hast Du Kontakt zu dem Herausgeber?
 
Zurück