English 中文(简体)
Error when using mailto: link in Mobile Safari in app-capable mode
原标题:

I ve got a form in a web page with an action that is "mailto:email" (where email is a real email address). When I load this page in Mobile Safari in regular mode (ie, not launched from home screen with app-capable mode), this works fine - after I submit the form, the email app comes up. However, when I m in app-capable mode and have launched from the home screen (so, no Safari chrome), and submit the form I get the error "URL can t be shown". However, a regular mailto: link (ie, not in a form) does work when in app-capable mode.

Has anyone else noticed this? Any workarounds? Are forms disallowed in app-capable mode?

Thanks,

Elisabeth

最佳回答

This accurately describes the issue. There is nothing wrong with the mailto link, the mailto link fails to load. Often the webapp crashes.

The funny thing is that tel: link for telephone numbers work fine.

window.location.replace does in-fact work. Thanks!

Here is the jQuery to fix this automatically...

$( a[href^=mailto] ).click(function (event) {
    event.preventDefault();
    window.location.replace = $(this).attr( href );
    return false;
});
问题回答

I think I ve figured this out. I noticed when in app-capable mode, any http link will take you out of the app and launch a separate mobile safari window, take you to the page and show the Safari chrome. Makes sense (typically one wouldn t link to anything from an "all in one" app-capable web app. I noticed this because I implemented a 4 page app with my own "tab bar" at the bottom and was linking amongst the .html files with plain http links in the a element. When I replace this with a javascript function to load the pages using document.location.replace this doesn t happen.

So, on the form - I think what must be happening is that because I m using a scheme (in this case, mailto:) somehow the browser is needed in "regular mode" to interpret the scheme and do the right thing by launching the email app and this clearly doesn t work when submitting a form. I haven t yet found anything in the Apple documentation specifically about this, so if anyone knows the technical details, please do post!

UPDATE: I did find that I can access a server side script using a form in web-app mode, so I m still curious about the mailto: issue, if anyone has an answer.

Thanks,

Elisabeth

I am having the exact same issue with mailto links not working in the web capable mode. I just got done submitting a bug report to Apple. Let s see what happens, meanwhile I found another dev. platform for web apps that works in web capable mode and mailto links work, but it is funny how it works in this even--it is not as fluid as it is in Safari. Because even in this new web dev tool that I found, it closes your app and launches mail client, which is lame. In Safari it just slides in a mail window that slides back out if you hit cancel or send--it doesn t actually close your app.

Here is a workaround that does not depend on JQuery:

aTmp = document.createElement("a");
aTmp.href="mailto:example@example.com?subject=Test&body=Hello.";
aTmp.click();

Update: To run this code from a bookmarklet you have to wait about 1000 ms before the bookmarks bezel is closed and the browser is ready to respond. I realized this by wrapping the code in a setTimeout function.





相关问题
Export to pdf on the client or server side?

My client side application is using jqgrid that requests the server side, which in its turn queries MySQL and sends back the resultSet in XML format. I m willing to add the export to PDF ...

Image generator

I d like to be able to generate an image with overlaying text (that is inputted by the user) such as how it is done on www.depressiondog.info. Can someone show/link me to some code that will do that. ...

Where should I put this configuration setting?

I m designing a fairly small web application which will run on a Sun application server (v9.1). It only has a few pages, no database of its own, and will retrieve/update data via web services. There s ...

服务器面与用户对用户的MVC在网络信号中

我最近找到了一种与《伙伴关系协定》有关的有趣的替代办法。 NET MVC,我目前做的是:静态超文本,配有先进的 Java本式服务电话(大多数例子使用开放式雷达)。 例如,见此或......。

MySQL Users and All Privileges

Ok, I m trying to add a user to a MySQL database. This user should be able to add other users to the database it has privileges for. So I did this: GRANT ALL privileges ON thedbname.* TO topuser @ % ...

Doesn t get into Debug Mode

When I Press F5 on my VS2005 to debug the application, it launches the web app window but it is coming out of debug mode. When I tried to trace the Error in the EventViewer, this was the error: ...

热门标签