简体   繁体   中英

Webapp homescreen title suggestion and jquery mobile

When user chooses "add to homescreen" option from mobile Safari she sees a dialog where she can enter title for that shortcut. The text field is already filled with some default title.

The question is: there this title is taken from?

In my code I have following header for one of my pages (all pages in single html file):

<div data-role="header" class="toolbar">
    <h1 id="someHeader" class="exampleHeader">Example Header</h1>
    <a href="#" onclick="loadOtherStuff()">Other</a>
</div>

I'm changing this title dynamically by using

var someDifferentTitle = ...
$('.exampleHeader').html(someDifferentTitle).trigger('create');

The title updates just fine but when I tap "add to homescreen" the system still uses original "Example Header" hint!

How to fix this? Any ideas?

Answer here: https://stackoverflow.com/a/11569043/275754

Short answer:

<meta name="apple-mobile-web-app-title" content="Short name">

OK, it turned out to be very simple, one just needs to change document's title:

document.title = someDifferentTitle

I still have no idea why the hint is truncated after several characters, but that is kind of enough for me.

I think however that there is slight inconsistency in jQM implementation. If setting toolbar's header in h1 using code changes the document title then dynamic change of header via .html() method should change the title as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM