Reputation: 22879
I'm developing a web page built for iPad's.
If the user is on a product page and they click on 'Add to Home Screen' button.
Is it possible to have the index.html page rather then current(product.html)?
OR ALTERNATIVELY
Would it be possible to have your own link that could be used on all a site pages.
When clicked use javascript to simulate the 'Add to Home Screen' button and have your 'index.html' page added?
Upvotes: 1
Views: 300
Reputation: 55544
You can't control anything about the Add to Home Screen button, not even "press" it using javascript, that is why sites like youtube have a little popover above the button, asking users to press it.
However you may be able to do something like this:
On each page on your website add javascript code like:
//Maybe check if the user is on an iPad???
if (window.location.href != "your home page url" && navigator.standalone) {
if (!document.referrer) {
window.location.href = "your home page url";
}
}
All that does is check if the user has added the webpage to the home screen navigator.referrer == true
, and then checks what webpage was visited previously, if it's nothing then the web app must have been started on a page that isn't the homepage, and so it should be sent to the homepage.
I've just typed that into the answer directly, so it may need some correction.
Upvotes: 2