Skip to content

Instantly share code, notes, and snippets.

@chengjianhua
Last active February 21, 2017 10:05
Show Gist options
  • Save chengjianhua/51f71fd75c369abed18cefc794be8c43 to your computer and use it in GitHub Desktop.
Save chengjianhua/51f71fd75c369abed18cefc794be8c43 to your computer and use it in GitHub Desktop.
the hack method that can make the title in weixin's webview be changable
hackSetTitle = (title) => {
document.title = title;
const iframe = document.createElement('iframe');
iframe.src = '/favicon.ico';
iframe.style.visibility = 'hidden';
const listener = () => {
setTimeout(() => {
iframe.removeEventListener('load', listener);
setTimeout(() => {
document.body.removeChild(iframe);
}, 0);
}, 0);
};
iframe.addEventListener('load', listener);
document.body.appendChild(iframe);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment