How to get/set current page URL (which works across space-time-browsers-versions)
问题 I want to get/set URL of the current page upon certain event. It seems there are more than one approach for doing it as mentioned in questions/answers below. Using Jquery Get URL - $(location).attr('href'); Set URL - $(location).attr('href',url); Using JavaScript Get URL - myVar = window.location.href; Set URL - window.location.href = "http://stackoverflow.com"; Which approach works across space-time-browsers-versions? Get current URL in JavaScript? How to redirect to another webpage in