简体   繁体   中英

Firefox 3.6 - location.href not working in JSP

I have JSP page with method = POST and action='/mydir/mypage/nextpage'

I have a button:

<button title='Continue' onclick="this.form.perform.value='cancelButton'; javascript:doCloseWindow();">Continue</button>

and JavaScript method like:

function doCloseWindow(){         
  location.href = "https://abc.xyz.com/mydir/?param=123";              
}

It does not work in Firefox 3.6. On click of button; it redirects to the path I mentioned in form action.

With Tamper data I find that the request goes to URL (as in method) with GET and then it redirects to form's action URL.

I added return false in the method call also -- javascript:doCloseWindow(); return false javascript:doCloseWindow(); return false

I tired various combinations like

window.location.href = "https://abc.xyz.com/mydir/?param=123";
window.document.location.href = "https://abc.xyz.com/mydir/?param=123";
document.location.href = "https://abc.xyz.com/mydir/?param=123";

But no success.

Remove the "javascript:" before the call to doCloseWindow.

At this point, you've already executed some JavaScript code in this event handler — it doesn't make sense to try to tell the browser again that the following code is JavaScript.

Try changing your Javascript call to:

function doCloseWindow(){
    alert('here');
    location.href = "https://abc.xyz.com/mydir/?param=123";
    return false;
}

I'm wondering if the function is actually running.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM