Question : Replace a window.location with A Href

the window.locatiopn.replace function works but what happens is it leaves the current page open whwn it opens a new page.  How can I force it to go to a new page while closing the exsiting page, can I use a Href as part of the Ajax script.
So instead of this
window.location.replace('stratplan.aspx?ID=' + Id);
I would liek to use something liek this
"<a HREF='stratplan.aspx?ID=" & Id "</a>"

This way it would go back to the page in the current view instead of opening a new window.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
if (req) {
                req.onreadystatechange = function() {
                    if (req.readyState == 4) {
                        if (req.responseText.indexOf("|") == -1) {
                            window.location.reload();
                        } else {
                        window.location.replace('stratplan.aspx?ID=' + Id);
                       "<a HREF='stratplan.aspx?ID=" & Id "</a>"
                        }

                    }
                };
                req.open("POST", "Include/AJAX.aspx?mode=iubm&id=" + document.frm.hidSid.value + "&il=" + insertList + "&ul=" + updateList + "&sid=" + sid, true);
                req.send(null);
                window.open('stratplan.aspx?ID=' + Id, '_Blank');

Answer : Replace a window.location with A Href

I have a very hard time understanding what you really want

This code will redirect the current page after the ajax has successfully completed
Perhaps you do not return a "|" which is what is tested

if (req.readyState == 4) { // ajax returned
                       if (req.responseText.indexOf("|") == -1) { // it did NOT have a pipe symbol in the return text: reload the page
                           window.location.reload();
                       } else { // it DID have a pipe symbol, replace the current page with a new page
                           window.location.replace('stratplan.aspx?ID=' + Id);
                       }

                   }

Random Solutions  
 
programming4us programming4us