[英]redirecting to next page
I wrote a javascript function to go to a particular page if it came from a particular page. 我写了一个javascript函数,如果它来自特定页面,则转到特定页面。
Function: 功能:
function proceed()
{
if( document.referer == "http://abcd.com/index.php?action=SignUp")
{
return document.location.href = "http://abcd.com/editprofile.php?action=editprofile";
}
}
Submit button for a form in current page(b): 当前页面中表单的“提交”按钮(b):
What i want is to go through a sequence of pages a->b->c , where a is previous , b is current , and c is next in my case. 我想要的是遍历页面a-> b-> c的序列,在我的情况下,其中a是上一个,b是当前,c是下一个。 b has a form, on submitting values to the form, it should also call the javascript function and then go to the page c. b有一个表单,在向表单提交值时,还应该调用javascript函数,然后转到页面c。
Can anybody help me find out where is the mistake? 谁能帮助我找出错误所在? Any help would be highly appreciated. 任何帮助将不胜感激。 Thanks. 谢谢。
To be more accurate you will have to provide more of your application's code. 为了更准确,您将必须提供更多的应用程序代码。
Solution seems to be the following. 解决方法似乎如下。 Use the submit attribute for your button: 对按钮使用Submit属性:
<button type="button" onclick="proceed(); alert('You are not authorized to execute this action!');">Click Me!</button
Since you have a form I guess there's also some php/cgi script that will handle the form's data!? 由于您有表单,我想还有一些php / cgi脚本可以处理表单数据!
In that case your form won't continue to that script if you override your submit button via javascript in such way that it loads another page (other cases like validation do work that way, of course). 在这种情况下,如果您通过javascript覆盖提交按钮的方式不能加载该脚本,则该表单将无法加载该页面(其他情况,例如验证也可以那样)。
So 所以
onclick = "javascript...
should be onclick="javascript...
. 您的提交按钮的onclick属性旁边有空格: onclick = "javascript...
应该是onclick="javascript...
Even after all syntax correction, there's still something odd. 即使在所有语法校正之后,仍然有些奇怪。 After all, you can only give one "next page" functionality to your submit button. 毕竟,您只能为“提交”按钮提供一个“下一页”功能。 So what should the form call: 那么表单应该调用什么:
proceed()
displaying page "c" and returning true so the form continues with its script. 在那种情况下,我建议从proceed()
显示页面“ c”并返回true的JavaScript弹出窗口,以便表单继续其脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.