location.href未重定向到https://urls


location.href not redirecting to https:// urls

一直在表单的Thankyou页面上使用以下内容,在5秒内重定向回表单,并在名称字段中巧妙地预填充值:

<script> setTimeout(function() {location.href = '<?php echo $var3['returnurl']  ?>?fullName[first]=<?php echo $var1['first'] ?>&fullName[last]=<?php echo $var2['last']  ?>'}, 5000); </script>

在returnurl字段为https://url之前效果良好。然后,它会在一个循环中停留在感谢页面上,试图进行重定向。没有涉及iframe。。。。已经尝试了top.location.href…不好。。。甚至尝试过定位。更换

有人能看到代码中可能影响重定向到https://url的任何限制吗。

php文件中的代码。。。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no"> 
  <meta name="HandheldFriendly" content="True">
  <meta name="MobileOptimized" content="width">
    <title>Thankyou</title>
    <style type="text/css">
body 
{
margin: 0px;
padding: 0px;
background: #fff;
font-family: Arial;
}
#message
{
position: absolute;
left: 50%;
width: 320px;
margin-left: -160px;
}
</style>
<?php
$answers = $_POST;
$var1 = array("first" => $answers[fullname][0]);
$var2 = array("last" => $answers[fullname][1]);
$var3 = array("returnurl" => $answers[returnurl]);
 ?> 
</head>
<body>
<script>
  setTimeout(function() {location.href = '<?php echo $var3['returnurl']  ?>?fullName[first]=<?php echo $var1['first'] ?>&fullName[last]=<?php echo $var2['last']  ?>'}, 5000); // this duration is in millisecs
</script>
<div id="message">
<p>&nbsp;</p>
<div style="text-align: center;"><h1>Thank You!</h1></div>
<div style="text-align: center;">Your submission has been received.</div>
<div style="text-align: center;">We're most grateful</div>
<div style="text-align: center;">&nbsp;</div>
<div style="text-align: center;"><img src="http://www.mazeguy.net/bigsmilies/thumbsup.gif"></img></div>
<div style="text-align: center;">&nbsp;</div>
<div style="text-align: center;">You will return in 5 seconds</div><br />
</body>
</html>

以下是提交的结果。。。感谢页面的来源显示。。。是的,安全页面url没有通过。。。。

<script>
setTimeout(function() {location.href = '?fullName[first]=&fullName[last]='}, 5000); //     this duration is in millisecs
</script>

您是否考虑过通过Ajax提交表单?用户永远不会离开表单提交页面。您可以简单地显示带有确认消息的模态。这似乎比重定向用户更简单。这可能也是一个更好的用户体验。

假设您的表单有一个submit按钮,该按钮的类为"submit"。你可以在jQuery:中这样做

$(function() {
    $('body').on('click', '.submit', function(event) {
        event.preventDefault();
        var target = event.currenTarget;
        var form = $(target).closest('form');
        var action = $(form).attr('action');
        $.post(action, form.serialize())
            .done(function() {
                alert('Thanks for your submission!');
            })
            .fail(function() {
                alert('Oops! Something went wrong... PLease try again.');
            });
    });   
});

查看引导程序。他们有一些漂亮的模式你可以使用。