Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9066073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:39:30+00:00 2026-06-16T16:39:30+00:00

I am trying to navigate to a new page using javascript. When I put

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:39:31+00:00Added an answer on June 16, 2026 at 4:39 pm

    This:

    function next(){
     $post = "?id=10
            alert($post);
         window.location.href = "next.html" + $post;
     }
    

    Is a syntax error in your PHP. Try this:

    <?php
        function next(){
         $post = "?id=10";
    ?>
         alert($post);
         window.location = "next.html" + <?php echo $post; ?>;
    <?php
        }
    ?>
    

    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:

    function next(){
     var post = "?id=10";
            alert(post);
     window.location = "next.html" + post;
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have MyPage.aspx html page (generated using ASP.Net). When user tries to navigate away
I'm trying to prevent full page reloads using Backbone's pushState. When I call navigate()
I trying to navigate my new EC2 setup and was hoping to find an
I have been trying to execute a button event in html page that displays
I'm trying to submit the page and forward to a new JSP. h:outputlink will
I am trying to navigate to a page from a ScrollViewer control: <Button x:Name=btnViewMenu
i am trying to navigate on windows phone 7.1 from one page to another
I'm trying to create a page using ASP.NET MVC 2 which shows two things:
I'm trying to get google search results using HTML Agility Pack, but I am
I am very new to JavaScript. Kindly note that I am trying below issue

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.