Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在ios应用程序中发送包含javascript的html电子邮件_Javascript_Html_Ios_Objective C - Fatal编程技术网

在ios应用程序中发送包含javascript的html电子邮件

在ios应用程序中发送包含javascript的html电子邮件,javascript,html,ios,objective-c,Javascript,Html,Ios,Objective C,我正在尝试从我的ios应用程序发送一封html(javascript标记)电子邮件。没有错误,但javascript将无法工作 我的代码如下: - (IBAction)sendDirection:(id)sender { // Email Subject NSString *emailTitle = @"example subject"; // Email Content NSString *messageBody = @"<html><head><script&

我正在尝试从我的ios应用程序发送一封html(javascript标记)电子邮件。没有错误,但javascript将无法工作

我的代码如下:

- (IBAction)sendDirection:(id)sender {

// Email Subject
NSString *emailTitle = @"example subject";
// Email Content
NSString *messageBody = @"<html><head><script>function initialize(){document.getElementById('directions').innerHTML = 'testing';}</script></head><body onload='initialize()'></div><span id='directions'></span></body></html>";
// To address
NSArray *toRecipents = [NSArray arrayWithObject:@"info@example.com"];

MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:YES];
[mc setToRecipients:toRecipents];

// Present mail view controller on screen
[self presentViewController:mc animated:YES completion:NULL];

}
-(iAction)发送方向:(id)发送方{
//电子邮件主题
NSString*emailTitle=@“示例主题”;
//电子邮件内容
NSString*messageBody=@“函数初始化(){document.getElementById('directions')。innerHTML='testing';}”;
//解决
NSArray*ToRecipients=[NSArray arrayWithObject:@”info@example.com"];
MFMailComposeViewController*mc=[[MFMailComposeViewController alloc]init];
mc.mailComposeDelegate=self;
[mc设置主题:emailTitle];
[mc setMessageBody:messageBody isHTML:YES];
[mc设置收件人:收件人];
//在屏幕上显示邮件视图控制器
[自我呈现视图控制器:mc动画:是完成:空];
}

许多电子邮件客户端禁用JavaScript以防止XSS攻击和其他漏洞。最好的选择是坚持使用普通的HTML+CSS,即使这样,一些更有趣的CSS功能也可能不可用,具体取决于客户端


很难说你想用JavaScript做什么,但最好是将所有编程都保持在Objective-C中,并仅将mail composer用于HTML标记。

您在其中查看HTML的内容是什么?Javascript在MFMailComposeViewController中不适用于这种类型的HTML。@connor:我在MFMailComposeViewController上使用它。@Inase-36:您知道wat会起作用吗,我想你必须使用你自己的服务器来发送电子邮件,这实际上可以评估javascripts。我试图获取google文本的方向,并将其作为电子邮件发送给用户。为什么你不能在没有javascript的情况下将其作为纯HTML发送?