I am trying to navigate to a new page using javascript. When I put window.location.href = “next.html” in the header of a page it works fine. but when calling it from a function after a button is clicked, it does not work. Example code:
function next(){
$post = "?id=10"
alert($post);
window.location.href = "next.html" + $post;
}
the alert displays ?id=10, but it does not redirect. Thanks for the help
The ” missing was a typo and is not in the real site, sorry!
This:
Is a syntax error in your PHP. Try this:
You really should not mix PHP with JavaScript like this how ever.
EDIT: Ok after confusion has been cleared – if no PHP is involved try: