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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:09:42+00:00 2026-06-05T01:09:42+00:00

I want to make it so the user clicks a link, they get a

  • 0

I want to make it so the user clicks a link, they get a confirm box. If they click OK, they get sent to a new php function.

I’ve tried:

function confirmReset() {
 var r = confirm('Are you sure?');
 var url = window.location.pathname;
 var pathArray = url.split('/');
 var host = pathArray[1];
 var newHost = '/headquarters/designReset';

 if (r == true) {
    window.location = host + newHost;
    //document.location.href = '/headquarters/designReset';
 } else {
    alert('it didnt work');
 }
 return false;
}​

Firebug error says:

SyntaxError: illegal character
}​

It’s saying that ​ is after the } at the end of the function. I’m getting this script externally so if you post an answer make sure it works externally. Not just in the html file itself. Ive had answers that dont. Thanks!

  • 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-05T01:09:46+00:00Added an answer on June 5, 2026 at 1:09 am

    There is no string method. It gives an error. Also consider adding return false to your function in order to prevent the default link action.

    HTML:

    <a href="#" onclick="return confirmReset();">Test</a>​
    

    JavaScript:

    function confirmReset() {
        var r = confirm('Are you sure?');
        var url = window.location.pathname;
        var pathArray = url.split('/');        // <-- no need in "string()"
        var host = pathArray[1];
        var newHost = '/headquarters/designReset';
    
        if (r == true) {
            window.location = host + newHost;
            //document.location.href = '/headquarters/designReset';
        } else {
            alert('it didnt work');
        }
        return false;                          // <-- add this line
    }​
    

    DEMO: http://jsfiddle.net/xKhaq/

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

Sidebar

Related Questions

I want to, when the user clicks a button on my website, to make
I want to make call to authenticate user and get back token in json
I want to make a user Control in WPf with same properties and events
I want to make a user-registration form where I will have fields such first
I want make interactive application where user launches it and can do various task
I want to make a site where there user can basically navigate the web
I want to make a program that will simulate a user browsing a site
If we want in our WPF application to let a user make a SQL
I have MOSS. I want to make a page where a user, say administrator,
I want the user to be able to make some preferences like colors, prefered

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.