Skip to content

Instantly share code, notes, and snippets.

@inawrath
Created September 29, 2020 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inawrath/d7b083c894c64a289df4776780ad7f0d to your computer and use it in GitHub Desktop.
Save inawrath/d7b083c894c64a289df4776780ad7f0d to your computer and use it in GitHub Desktop.
Open Tab in iOS Safari with JavaScript vanilla
const loadingPage = `
<style>
/*Huge thanks to @tobiasahlin at http://tobiasahlin.com/spinkit/ */
.spinner {
margin: 100px auto 0;
width: 70px;
text-align: center;
}
.spinner > div {
width: 18px;
height: 18px;
background-color: #333;
border-radius: 100%;
display: inline-block;
-webkit-animation: sk-bouncedelay 1.4s infinite ease-in-out both;
animation: sk-bouncedelay 1.4s infinite ease-in-out both;
}
.spinner .bounce1 {
-webkit-animation-delay: -0.32s;
animation-delay: -0.32s;
}
.spinner .bounce2 {
-webkit-animation-delay: -0.16s;
animation-delay: -0.16s;
}
@-webkit-keyframes sk-bouncedelay {
0%, 80%, 100% { -webkit-transform: scale(0) }
40% { -webkit-transform: scale(1.0) }
}
@keyframes sk-bouncedelay {
0%, 80%, 100% {
-webkit-transform: scale(0);
transform: scale(0);
} 40% {
-webkit-transform: scale(1.0);
transform: scale(1.0);
}
}
</style>
<div class="spinner">
<div class="bounce1"></div>
<div class="bounce2"></div>
<div class="bounce3"></div>
</div>
`;
const asyncFunction = async (randomParams, newTab) => {
try {
/**
* Process your requests or call async function
*/
if (newTab.location) {
newTab.location = "https://www.google.com";
}
} catch(err) {
if (newTab.close) {
newTab.close();
}
/**
* Process error
*/
}
}
const callAsyncFunction = () => {
const randomParam = "Hello World";
let newTab;
if (typeof window === "object") {
newTab = window.open();
if (newTab) {
newTab.document.body.innerHTML = loadingPage;
}
}
asyncFunction(randomParam, newTab);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment