-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
title: Safari back-forward-cache override | ||
description: | ||
#featuredImg: async.webp | ||
createdAt: 05/03/2024 | ||
tags: | ||
- javascript | ||
- safari | ||
--- | ||
|
||
<div class="c-code-wrapper"> | ||
<div class="c-code-wrapper__header"> | ||
<div class="c-code-wrapper__title">Safari back-forward-cache override</div> | ||
<div class="c-code-wrapper__copy">Copy</div> | ||
</div> | ||
|
||
```js [js] | ||
// Safari back-forward-cache override | ||
(function () { | ||
window.onpageshow = function (event) { | ||
if (event.persisted) { | ||
document.body.style.opacity = 0; | ||
window.location.reload(); | ||
} | ||
}; | ||
})(); | ||
``` | ||
|
||
</div> | ||
|
||
## Further reading | ||
|
||
- https://stackoverflow.com/a/13123626/5527156 | ||
- https://web.dev/articles/bfcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
title: Get all non native window variables | ||
description: | ||
#featuredImg: async.webp | ||
createdAt: 05/03/2024 | ||
tags: | ||
- javascript | ||
- window | ||
--- | ||
|
||
<div class="c-code-wrapper"> | ||
<div class="c-code-wrapper__header"> | ||
<div class="c-code-wrapper__title">Get all non native window variables</div> | ||
<div class="c-code-wrapper__copy">Copy</div> | ||
</div> | ||
|
||
```js [js] | ||
// Get all non native window variables | ||
|
||
(function showAllNonNativeWindowProperties() { | ||
const iframe = document.createElement("iframe"); | ||
iframe.style.display = "none"; | ||
document.body.appendChild(iframe); | ||
|
||
const currentWindowProps = Object.getOwnPropertyNames(window); | ||
|
||
const allNonNativeProps = currentWindowProps.filter(function (prop) { | ||
return !iframe.contentWindow.hasOwnProperty(prop); | ||
}); | ||
|
||
for (const prop of allNonNativeProps.sort()) { | ||
console.log(`Saabbir ${prop}: `, window[`${prop}`]); | ||
} | ||
|
||
document.body.removeChild(iframe); | ||
})(); | ||
``` | ||
|
||
</div> | ||
|
||
## Further reading | ||
|
||
- https://stackoverflow.com/questions/17246309/get-all-user-defined-window-properties |