React Native
React Native
Example: Http.ExtractMetaRefreshUrl method
Demonstrates theExtractMetaRefreshUrl method.
Chilkat React Native Downloads
import { Http, StringBuilder } from '@chilkat/react-native'
function chilkatExample() {
const http = new Http();
// Sample HTML with a META refresh.
// <!DOCTYPE html>
// <html lang="en">
// <head>
// <meta charset="utf-8" />
// <meta http-equiv="refresh" content="5; url=https://example.com" />
// <title>Meta Refresh Redirect</title>
// </head>
// <body>
// <p>Redirecting to example.com in 5 seconds�</p>
// </body>
// </html>
const sb = new StringBuilder();
const bCrlf = true;
sb.appendLine('<!DOCTYPE html>', bCrlf);
sb.appendLine('<html lang="en">', bCrlf);
sb.appendLine('<head>', bCrlf);
sb.appendLine(' <meta charset="utf-8" />', bCrlf);
sb.appendLine(' <meta http-equiv="refresh" content="5; url=https://example.com" />', bCrlf);
sb.appendLine(' <title>Meta Refresh Redirect</title>', bCrlf);
sb.appendLine('</head>', bCrlf);
sb.appendLine('<body>', bCrlf);
sb.appendLine(' <p>Redirecting to example.com in 5 seconds�</p>', bCrlf);
sb.appendLine('</body>', bCrlf);
sb.appendLine('</html>', bCrlf);
try {
const url = http.extractMetaRefreshUrl(sb.getAsString());
console.log(`META refresh URL: ${url}`);
} catch {
console.log('The HTML has no META refresh tag.');
}
}