我需要在我的Android应用程序WebView中显示iframe,iframe存在于位于Web服务器上的HTML文件中。 我需要添加一个参数到iframe源,然后在WebView中显示它,具体取决于用户输入。将参数添加到iframe源
我的PHP代码:
<?php
if (isset($_POST['amount'])){
$amount = $_POST['amount'];
$intamount = (int)$amount;
echo $intamount;
}
if (isset($_POST['currency'])){
$currency = $_POST['currency'];
$intcurrency = (int)$currency;
}
if (isset($_POST['lan'])){
$lan = $_POST["lan"];
}
if (isset($_POST['email'])){
$email_address = $_POST["email"];
}
if (isset($_POST['name'])){
$name = $_POST['name'];
}
$iframe_source = 'https://sampleurl.php?sum='.$intamount.'¤cy='.$intcurrency.'&cred_type=1&trButtonColor=008080&email='.$email_address.'&contact='.$name;
echo $iframe_source;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<iframe width="370" height="455" src="<?php
echo $iframe_source;
?>" frameborder="5" allowfullscreen></iframe>
</body>
</html>
我可以做一个POST请求的PHP文件,例如要做到这一点?如果是的话,有没有办法在PHP文件中添加html代码并将其显示在我的WebView中? 有没有更好的方法来做到这一点? 非常感谢。
这不是一个真正的来源,它只是一个例子,我需要能够根据用户输入来调整它来回我的Android应用程序 –
当然,sampleurl只是一个例子,真正的是你提供的格式,它工作正常,我猜是在接收参数之前显示iframe,这可能是我得到该错误的原因 –