开发者

redirecting to next page

I wrote a javascript function to go to a particular page if it came from a particular page.

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):

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. b has a form, on submitting values to the form, it should also call the javascript function and then go to the page c.

Can anybody help me find out where is the mistake? Any help would be highly appreciated. Thanks.


Since you have a form I guess there's also some php/cgi script that will handle the form's data!?
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).

So

  1. Your submit button has spaces next to the onclick attribute: onclick = "javascript... should be onclick="javascript....
  2. Your function proceed() should return true for the submit to perform.
  3. 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:

    • your php or cgi script? Then you can build a redirect to page "c" into that one.
    • your page "c"? Then what do you need the form for?
    • both, but independently? In that case I suggest a javascript popup from proceed() displaying page "c" and returning true so the form continues with its script.


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:

<button type="button" onclick="proceed(); alert('You are not authorized to execute this action!');">Click Me!</button
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜