Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have an old application, in which i am using VB script MsgBox. Now i am making the application Chrome compatible, in which VB script wont work, So i create a function below

JavaScript
function MsgBoxClass(header) {
this.returnvalue = 0;

this.modalalert = function msgBox() {
    var modalDiv = '<div id="dvModal" class="modal hide">' +
        '<div class="modal-header">' +
        '<table style="width:100%;">' +
        '<tr>' +
        '<td style="width:70%;text-align:left">' +
        '<h3 id="ModalHeader"></h3>' +
        '</td>' +
        '<td style="width:30%;text-align:right">' +
        '<a class="close" >×</a>' +
        '</td>' +
        '</tr>' +
        '</table>' +
        '</div>' +
        '<div id="dvModalBody" class="modal-body">' +
        '</div>' +
        '<div class="modal-footer" id="dvModalFooter">' +
        '<a class="btn" id="modalCancleButton" data-dismiss="modal" >Cancle</a>' +
        '<a class="btn" id="modalYesButton" data-dismiss="modal" >Yes</a>' +
        '</div>' +
        '</div>';
    $("body").append(modalDiv);
    $("#dvModalBody").html(header);
    $("#dvModal").modal({
        keyboard: false,
        backdrop: 'static',
        show: true
    });
};

this.msgBoxOkClick = function msgBoxOkClick() {
    this.returnValue = 3;
};

this.msgBoxCancleClick = function msgBoxCancleClick() {
    this.returnValue = 4;
};


and using it in our code like this,
JavaScript
var messagebox = new MsgBoxClass('message');

function msgboxcall() {
        messagebox.modalalert();
        return messagebox.returnvalue;

    }


But irrespective of button selection it always returning default value O. because execution wont halt until user selects the button.

Is there any way that i can pause the execution until user clicks on the button if his choice??

Please help me out.
Posted
Comments
Sergey Alexandrovich Kryukov 21-Oct-14 12:14pm    
There is no such thing a "Java script". Java is not a scripting language. ;-)
—SA
jaket-cp 21-Oct-14 12:27pm    
The javascript confirm() method may fix your purpose.
http://www.w3schools.com/jsref/met_win_confirm.asp
vbscript - I have not touched take for some time.

1 solution

As you are using jQuery already, you can use the jQuery UI Dialog plug-in: http://jqueryui.com/dialog[^].

In a pinch, you could use modal pop-up dialogs alert or confirm:
http://www.w3schools.com/jsref/met_win_alert.asp[^],
http://www.w3schools.com/jsref/met_win_confirm.asp[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900