我制作了一个带有联系表格的 Flash 网站,它可以在我的电脑上的 FireFox、IE 和 Chrome 中完美运行。但是,在 Safari 中,我似乎无法输入任何文本字段;在Android上,我只能输入大写字母(基本上大写锁定已打开,它不会让我更改为小写)。
我怀疑问题完全出在 Flash 中,因为发送电子邮件确实可以正常工作。在此处或在 Google 上搜索并没有让我找到任何相关内容。
有小费吗?
这是我的代码:
FormScript.as(这是从我的主 .as 文件调用的外部 .as 文件)
//***All imports, vars, etc***
function submit(e:MouseEvent):void {
//Check to see if any of the fields are empty
if(yourName.text == "" || fromEmail.text == "" ||
yourSubject.text == "" ||yourMsg.text == "" ) {
valid.text = "All fields must be filled";
}
//Check if you're using a valid email address
else if(!checkEmail(fromEmail.text)) {
valid.text = "Please fill in an existing email";
}
else {
valid.text = "Verzenden..";
var emailData:String =
"name=" + yourName.text +
"&from=" + fromEmail.text +
"&subject=" + yourSubject.text +
"&msg=" + yourMsg.text;
var urlVars:URLVariables = new URLVariables(emailData);
urlVars.dataFormat = URLLoaderDataFormat.TEXT;
urlRequest.data = urlVars; varLoad.load( urlRequest );
varLoad.addEventListener(Event.COMPLETE, thankYou );
}
}
function reset(e:MouseEvent):void {
init(); //call the initial clear function
}
function checkEmail(s:String):Boolean {
//This tests for correct email address
var p:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
var r:Object = p.exec(s);
if( r == null ) {
return false;
}
return true;
}
function thankYou(e:Event):void {
var loader:URLLoader = URLLoader(e.target);
var sent = new URLVariables(loader.data).sentStatus;
if( sent == "yes" ) {
valid.text = "Thanks for your email!"; timer = new Timer(500);
timer.addEventListener(TimerEvent.TIMER, msgSent);
timer.start();
}
else {
valid.text = "Something went wrong, please try again";
}
}
function msgSent(te:TimerEvent):void {
if(timer.currentCount >= 10) {
init();
timer.removeEventListener(TimerEvent.TIMER, msgSent);
}
用于邮件处理的 PHP 文件:
<?php
$yourName = $_POST['name'];
$fromEmail = $_POST['from'];
$yourSubject = $_POST['subject'];
$yourMsg = $_POST['msg'];
if( $yourName == true ) {
$sender = $fromEmail;
$yourEmail ="myemailaddress@example.com"; // Naturally I put in my own email address here :)
$ipAddress = $_SERVER['REMOTE_ADDR']; // This gets the user's ip Address
$emailMsg = "Van: $sender\r\n" .
"Naam: $yourName\r" .
"Subject: my site - $yourSubject\n\n" .
"$yourMsg\n\n\n\n" .
"------------------------------\r" .
"Verstuurd vanaf IP-adres $ipAddress\r" .
"X-Mailer: PHP/" . phpversion();
$return = "From: $sender\r\n";
if( mail( $yourEmail, "$yourSubject", $emailMsg, $return)) {
echo "sentStatus=yes";
}
else {
echo "sentStatus=no";
}
}
?>
编辑:
我已经设法解决了这个问题。Safari 仍然不让我输入。
我更改了标题 -原始问题: “Android 上的 Flash 表单让我只能输入大写字母/CAPS,Safari 根本不允许我输入”
可能对 Android 起到作用的部分是将文本字段设置为 for.htmlText
而不是.text
在 AS3 代码中。