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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:59:41+00:00 2026-05-13T11:59:41+00:00

Scenario is : old site which has lots of JS code already written. If

  • 0

Scenario is : old site which has lots of JS code already written. If user want to change all the alert messages to new age jazzy Div based alert which are very common using JQuery, YUI, Prototype… etc.
There are mainly tree JS dialogs
1. alert

To changes this its simple we just have to write new function which will show the div popup and show the message, after that override the window.alert


function showDivAlert(strMessage){
//div popup logic and code
}

window.alert = showDivAlert;

2. prompt

This too look easy to write function to accept the string and show the text box for input value. Now as return action is based on the click of “OK” button life is easy here.


function shoDivPromp(strMessage){
//div pop up to show the text box and accept input from the user
}
window.prompt = shoDivPromp;

3. confirm

Now above two were easy to override and modify the default dialogs but there is complication with the confirm.
However default JS confirm dialog stops JS execution and when user click OK or Cancel execution is resumed by determining the return value (true/false). But if we user div popup the execution is not stopped which is problem.
We can still implement the confirm but in that case we have to bind methods for OK and CANCEL case which will be attached to OK and CANCEL button. With this function signature will be like.
function newConfirm(msg, fun OkAction(), fun CancelAction)

Now this is problem that this cant help me change the confirm dialog across the site as we did with alert();
Question
I am not sure whether its possible or not to achieve but i think can be using some JS pattern. So let me know if its possible.

  • 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-05-13T11:59:41+00:00Added an answer on May 13, 2026 at 11:59 am

    Now this is problem that this cant help me change the confirm dialog across the site as we did with alert();

    That’s correct. It’s not possible to reproduce the synchronous nature of the alert/confirm/prompt functions in native JavaScript. There is the non-standard method showModalDialog which can do it using a separate pop-up document, but it’s not supported by all browsers and it’s generally considered highly undesirable.

    So the plug-in-replacement strategy isn’t going to work. You are going to have to change every place you called these methods in the rest of the script.

    The usual pattern is to do it using inline anonymous functions, to preserve the local variables using a closure, eg. replace:

    function buttonclick() {
        var id= this.id;
        if (confirm('Are you sure you want to frob '+id+'?'))
            frob(id);
        wipe(id);
    }
    

    with:

    function buttonclick() {
        var id= this.id;
        myConfirm('Are you sure you want to frob '+id+'?', function(confirmed) {
            if (confirmed)
                frob(id);
            wipe(id);
        });
    }
    

    If you need this to be preserved you would need to look at a further nested closure or function.bind to do it. If you have your call to confirm in a loop things get considerably more difficult.

    Obviously you also have to ensure that critical global state doesn’t change whilst the confirm box is up. Usually this risk is minimised by greying out the rest of the page with an overlay to stop clicks getting through. However if you have timeouts they can still fire.

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

Sidebar

Related Questions

We have a data driven ASP.NET website which has been written using the standard
My site assigns each user a fake subdomain along the lines of http://username.mysite.com/ which
Here's the scenario, the old database has this kind of design dbo.Table1998 dbo.Table1999 dbo.Table2000
Scenario: A stored procedure receives from code a DateTime with, let's say DateTime.Now value,
Scenario You've got several bug reports all showing the same problem. They're all cryptic
We are going to redesign a large web service which has around 25 unique
I want to hide a Sharepoint web that has been deprecated (via custom means)
The scenario is as follows. We have 2 servers; one 'old' running old webshop
Found several good(related) questions here and here but all are nearly a year old.
The Scenario I have an application where we took the good old query string

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.