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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:45:36+00:00 2026-06-13T13:45:36+00:00

Sysadmin and coding ignoramus tries to make a simple job page. It has a

  • 0

Sysadmin and coding ignoramus tries to make a simple job page. It has a simple javascript function:

function run(job){
    var ok = confirm("Are you sure?");
    if(ok == true){
        location = 'job.php?op=' + job;
        window.location.href = location;
    } else {
        window.location.reload();
    }
}

Called by a simple button:

<button style="color: red" onclick="run('test1');">Test1</button>

Keyword here being simple, like my understanding.

This worked in Chrome, but the button does nothing in Firefox (current versions of both browsers).

In trying to debug the script I added a simple alert line before the .href so the script reads like so:

function run(job){
    var ok = confirm("Are you sure?");
    if(ok == true){
        location = 'job.php?op=' + job;
        alert(location);
        window.location.href = location;
    } else {
        window.location.reload();
    }
}

… and then the script also worked in Firefox. I could see the alert appear briefly but it redirected instantly and disappeared in a fraction of a second. But in Chrome the popup persists so it’s not a good workaround, and the behaviour in Firefox is weird which tells me I’m doing-it-wrong.

My question is, why does the script behave inconsistently, and how can I avoid this behaviour so it is consistent in both browsers, and doesn’t require an additional alert()?

  • 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-13T13:45:37+00:00Added an answer on June 13, 2026 at 1:45 pm

    I think the issue might be that location is equivalent to window.location in that context. As you’ve not made location a local variable it will be an implied global.

    Rename your location variable to something else or change it to a local variable by using ‘var location’:

        var location = 'job.php?op=' + job;
        alert(location);
        window.location.href = location;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a test user that has sysadmin right in SQL Server 2005
I'm using Jira and have been told by the sysadmin that GreenHopper has been
If I run this query, does that give sysadmin rights to the database the
A sysadmin teacher told me one day that I should learn to use make
I know I can't make my user in RDS a sysadmin...but can I at
As a sysadmin, I end up doing some simple ad-hoc programming every once in
Our sysadmin renamed several of our AD groups that we are using in SQL
I want to distribute a sysadmin utility inside our company that depends on not-yet-released
My requirement is that user performing alter CANNOT be sysadmin (it can have all
Previously for all our asp.net applications we have been using a sysadmin user within

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.