How to use window.location.replace javascript?
        Posted  
        
            by 
                william
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by william
        
        
        
        Published on 2011-11-28T09:44:10Z
        Indexed on 
            2011/11/28
            9:50 UTC
        
        
        Read the original article
        Hit count: 206
        
JavaScript
|html
My URLs
http://www.mysite.com/folder1/page1.aspx
http://www.mysite.com/folder1/page1.aspx?id=1
http://www.mysite.com/folder1/page1.aspx?id=1&dt=20111128
Redirecting Page
http://www.mysite.com/folder1/page2.aspx
I want to redirect from page1.aspx to page2.aspx
How to write a javascript in page1.aspx?
window.location.replace("/page2.aspx");
window.location.replace("../page2.aspx");
window.location.replace("~/page2.aspx");
First 2 gave me this.
http://www.mysite.com/page2.aspx
Last 1 gave me this.
http://www.mysite.com/folder1/~/page2.aspx
What is the correct way to use?
© Stack Overflow or respective owner