JavaScript - Javascript - execScript command

Asked By Murugan V on 24-Nov-08 07:06 AM
Hello,
we are executing the vbscript code thru javascript using execScript.
Example:
 execScript("n=MsgBox('Do you wish to delete?','4132','Confirmation Message')","vbscript");

The above command executing the script properly, but i do not want title message like "vbscript: Confirmation Message". I would like to hide the word "vbscript".
Is there any possibilities to hide?

please let me know, if anyone knows.

Thanks in Advance,
Murugan.V

re

Web Star replied to Murugan V on 24-Nov-08 07:10 AM

use simply this

win.execScript("alert('Do you wish to delete?')", "javascript");

Buttons

Murugan V replied to Web Star on 24-Nov-08 07:20 AM
I do not want the "Ok" & "Cancel" button in the alert message. My user wants "Yes" & "No" buttons in the message box. That is the reason,i'm using the vbscript instead of javascript.

fake the VBScript MsgBox with Javascript

mv ark replied to Murugan V on 24-Nov-08 08:04 AM
Rather than use the execScript method that works only in IE, I suggest that you create a pop window using window.open() to fake the VBScript MsgBox functionality. As you can control the child window features, you can remove scrollbar, addressbar etc, to create a custom alert box.
Re :: Javascript execScript command
Shailendrasinh Parmar replied to Murugan V on 24-Nov-08 08:16 AM

//Check this, a code posted by another expert in this forum
<script language="JavaScript">
     function alertBox(alertMessage,height,width)
          {
          // This stuff centers the window
          windowWidth = (width == null) ? 200 : width; // width of the new window
         windowHeight = (height == null) ? 30 : height; // height of the new window
         windowLeft = (screen.width / 2) - (windowWidth / 2); // center the window right to left
         windowTop = (screen.height / 2) - (windowHeight / 2); // center the window top to bottom
         
          // the values get inserted into the features parameter of the window.open command...
          var windowLocation = "top=" + windowTop + ",left=" + windowLeft + ",height=" + windowHeight + ",width=" + windowWidth;
          alertWindow = window.open("","alertWindow",windowLocation);
          alertWindow.document.write("<html><head><title>Alert!</title></head><body bgcolor='#C0C0C0'>");
          alertWindow.document.write("<div align='center'>" + alertMessage + "<br>");
          alertWindow.document.write("<form><input type='button' value=' YES ' onclick='window.close()' align='center'></form>");
          alertWindow.document.write("</div></body></html>");
          }
</script>


// Here is the call:
<input type="button" value="test" onclick="alertBox('This is an alert!!!')">

Hope this helps

Re :: Just give a try.
Shailendrasinh Parmar replied to Murugan V on 24-Nov-08 08:20 AM

Try this

execScript("n=MsgBox('Do you wish to delete?','4132','Confirmation Message')","");

Hope this helps.

Re :: Javascript execScript command
Shailendrasinh Parmar replied to Murugan V on 24-Nov-08 08:21 AM

Try setting window.event.returnValue.

function confirm()
retval = msgbox("Are you sure?", vbYesNo)
if retval = vbYes then
window.event.returnValue = true
else
window.event.returnValue = false
end if
end function

<asp:button id="btnCancel" Text="Cancel" Runat="server"></asp:button>

btnCancel.Attributes.Add("oncl*ick", "vbscript: confirm()");

Hope this helps.

Re :: Javascript execScript command (Yes - No Buttons)
Shailendrasinh Parmar replied to Murugan V on 24-Nov-08 08:24 AM

See the following article

http://www.perlscriptsjavascripts.com/js/alertboxes.html

Hope this helps.

Re :: Javascript execScript command (Yes - No Buttons)
Shailendrasinh Parmar replied to Murugan V on 24-Nov-08 08:25 AM

See the following article for messagebox with Yes No Buttons,

http://www.eggheadcafe.com/community/aspnet/2/10049582/how-to-display-the-messag.aspx

Hope this helps.

try this example
C_A P replied to Murugan V on 25-Nov-08 06:53 AM

<html>
<body>
<script language="JavaScript">
function function1() {
    var m = window.execScript("alert('test');""JavaScript");
    alert("The method returns always "+'"'+m+'"')

</script>
<input type="button" value="Click to execute the script" onclick="function1();">
</body>
</html>

Message
Murugan V replied to C_A P on 26-Nov-08 12:59 AM
I do not want the "Ok" & "Cancel" button in the Confirm message. My user wants "Yes" & "No" buttons in the Confirm message box.