Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Auslesen von RSS-Feeds in JavaScript (CORS Problem?)

Empfohlene Antworten

Veröffentlicht

Hallo,

ich möchte von einer lokalen Html per XMLHttpRequest auf einen RSS-Feed zugreifen um diesen dann in einem Canvas wie in einem Ticker laufen zu lassen.

Im IE funktioniert das, abgesehen von einer störenden MessageBox, ganz gut.

In FireFox und Chrome bekomme ich leider immer den Status 0.

Ich vermute das liegt daran, dass cross-origin-resource-sharing disabled ist.

Habe schon versucht per setRequestHeader('Access-Control-Allow-Origin','*') CORS zu enablen, leider ohne Erfolg.

Hier mein Code:

Script (RSSscript.js):

var loadRSSFeeds, myHandler;

var xhr;

myHandler = function (url) {

if (xhr.readyState == 4) {

if (xhr.status == 200) {

alert(xhr.responseText);

}

}

};

loadRSSFeeds = function (url) {

xhr = new XMLHttpRequest();

xhr.open("GET", url, true);

xhr.setRequestHeader('Accept', 'application/rss+xml');

xhr.onreadystatechange = myHandler;

xhr.send(null);

};

Html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head>

<title>Untitled Page</title>

</head>

<script src="RSSscript.js" language="javascript"></script>

<body>

<div id="main">

<div class="tube">

<div id="content"><a href="javascript:void(0);" onclick="loadRSSFeeds('http://www.n24.de/2/index.rss');">Grab the RSS Feeds!</a></div>

</div>

</div>

</body>

</html>

Zu diesem Thema gibt es eine Menge Foren und Diskussionen, leider hab ich bisher noch keine Lösung gefunden.

Hoffe hier auf mehr Erfolg.

Danke im Voraus

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.