我有一个输入,提交时会重定向到另一个页面,我希望此页面使用表单输入重定向到另一个页面:
<form id="composeLink" method="post" name="composeLink" action="{$address}/" >
<input type="hidden" name="username" value="{$fields['username']}" />
<input type="hidden" name="password" value="{$fields['password']}" />
<input type="hidden" name="login" value="1" />
</form>
<script type="text/javascript">
//document.form.action = document.form.action.replace("http","https");
document.getElementById('composeLink').submit();
</script>
使用smarty发送此表单的操作方法。问题是链接不正确。例如:当前链接为http://test.com,表单操作为http://action.com,重定向页面的链接已合并。
LE:行动表格发送正确
可能是什么问题?
答案 0 :(得分:1)
问题出现在您的模板引擎上,没有问题,我的意思是在HTML上。但是你可以写一个javascript并解决这个问题。如果你的行动是这样产生的(test.com/http://action.com),请写下这个:
<script type="text/javascript">
var newAction = document.getElementById("composeLink").action.split("http://");
document.getElementById("composeLink").action = "http://" + newAction[1];
document.getElementById('composeLink').submit();
</script>
如果你的动作是这样生成的(http://test.com/http://action.com),请写下这个:
<script type="text/javascript">
var newAction = document.getElementById("composeLink").action.split("http://");
document.getElementById("composeLink").action = "http://" + newAction[2];
document.getElementById('composeLink').submit();
</script>
不同的是您生成的网址,如果有两个&#34; http&#34;在您的URL上(对于拆分),您必须使用我编写的最后一个代码