Skip to content

Instantly share code, notes, and snippets.

View MJKSabit's full-sized avatar
📖
!stopLearning

Md. Jehadul Karim MJKSabit

📖
!stopLearning
View GitHub Profile
@MJKSabit
MJKSabit / getTitleNative.js
Created January 24, 2021 01:44 — forked from jbinto/getTitleNative.js
Get title from remote HTML URL - without jQuery
// Only using native browser features (no jQuery).
// Uses `fetch`, `DOMParser` and `querySelectorAll`.
const getTitle = (url) => {
return fetch(`https://crossorigin.me/${url}`)
.then((response) => response.text())
.then((html) => {
const doc = new DOMParser().parseFromString(html, "text/html");
const title = doc.querySelectorAll('title')[0];
return title.innerText;