What is the best way to push a user to another page?
I am using jQuery 1.6.2.
I have a function in a page that needs to direct the user to another page within the site and pass some variables along with it.开发者_StackOverflow
The function will post some data, then retrieve some data and then make a decision on where to take the user next.
Is this the best way to move someone to a specific page?
Is this the best way to code this piece?
QueryString = "?ArtistID=" + ArtistID;
window.location = 'MyNewPage.cfm' + QueryString
What other options are there?
You should be modifying href (and i would inline the pointless global variable )
window.location.href = 'MyNewPage.cfm?ArtistID=" + ArtistID;
This is a generally valid and accepted way to change location.
A few other ways could also work:
location.href = str;
location.assign(str);
location.replace(str); //Doesn't create new entry in the back button history
Use the following property
document.location.href = theUrl;
精彩评论