[Safari] How to randomly display the Smart App Banner, which allows you to promote apps on your website, using JavaScript

[Safari] How to randomly display the Smart App Banner, which allows you to promote apps on your website, using JavaScript

Hello, this is naouniverse ( @naouniverse708 ).

Smart App Banner, which allows you to promote your app on your website;

[Safari] How to randomly display the Smart App Banner, which allows you to promote apps on your website, using JavaScript

I wanted to display this multiple times at random, so I tried using JavaScript.

First, if you want to write the id in a fixed manner,

<meta name="apple-itunes-app" content="app-id=730429992">

app-id is any ID.
this
Mobile Safari will now display a promotional banner for the specified app at the top of the browser.

And if you want to display this randomly using JavaScript,

<script type="text/javascript"> /* 数字はアプリの数 */ var n = 2; var ad = new Array(n); /* 配列の各要素に任意のmetaを追加 */ ad[0] = '<meta name="apple-itunes-app" content="app-id=730429992">'; ad[1] = '<meta name="apple-itunes-app" content="app-id=693203609">'; /* meta追加ここまで */ /* 乱数発生 */ var x = Math.floor( Math.random() * n ); /* 出力 */ document.write(ad[x]); </script>

yes,

How to randomly display advertisements such as link shares using JavaScript

I used the contents as is.

[Safari] How to randomly display the Smart App Banner, which allows you to promote apps on your website, using JavaScript

[Safari] How to randomly display the Smart App Banner, which allows you to promote apps on your website, using JavaScript

It changes randomly each time you access it.

If you are an iOS app developer and have your own website, I think it's worth doing.

  • Add this entry to Hatena Bookmarks

At "naouniverse.com", the administrator writes about things, things, and the world that interest him.
Gadgets, cameras, design, programming, L'Arc~en~Ciel, etc...