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 8463529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:28:46+00:00 2026-06-10T14:28:46+00:00

My link looks like this: http://localhost:8081/wordpress/?p=535 How can I redirect to this page with

  • 0

My link looks like this:

 http://localhost:8081/wordpress/?p=535

How can I redirect to this page with JavaScript? I’m unfamiliar with the ? syntax, but I have a feeling I should be able to send some sort of request with the ID of the post?

Something like:

redirect("p="+postid);

Just calling window.Location won’t work for me because if the post doesn’t exist, then I want to be able to do something else. Also, I don’t want it to direct to local host. It needs to direct to the root of the website…

More like this then:

if (request("p="+postid) exists) {
    redirect("p="+postid);
}
  • 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-10T14:28:47+00:00Added an answer on June 10, 2026 at 2:28 pm
    document.location.href = "http://localhost:8081/wordpress/?p=535";
    

    If you want to check if the page exists first, you could do this :

    var addr = "/wordpress/?p=535"; // here with a relative url
    $.ajax({
        type: 'HEAD',
        url: addr,
        success: function() {
            document.location.href = addr;
        }
    });
    

    This will make a HEAD request (so no content download) to check if the page exists and only change the current location if it’s OK.

    Note that you may do that without jQuery if you want, I let you determine the exact syntax if needed.

    But this can only work if both page are from the same domain.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I opened a link which looks exactly like this: http://localhost/anysite/#data_aa Then, jquery performs the
I have a flash file (full link to flash looks like http://localhost:8888/PROJECT/swf/audio/player.swf ) which
I have a link that looks like this: <a onclick=myLightbox rel=lightbox href=image.jpg title=> I
I need to lift the YouTube link from some text which looks like this:
The link for logging in looks like this: <%= Html.ActionLink(Log On, LogOn, Account) %>
I have a CSS link that looks like this: <link href=../../css/WW/parts.css type=text/css rel=stylesheet />
I would like file_get_contents to get a url that looks like this: http://wapedia.mobi/sv/Gröt The
I am trying to pass parameters to a URL which looks like this: http://www.foobar.com/foo?imageurl=
I'm new to cakephp...and I have a page with a url this: http://localhost/books/filteredByAuthor/John-Doe so
Say you have a link with a relative path that looks like this: <a

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.