Remove CANCEL option from javascript window

How can I modify this basic javascript script to remove the Cancel button which always displays in both MSIE and FIREFOX, along with the OK button. It may be there is no way, or not even a better way but I'd like to know for sure.

I want to show the user a window that does not give any sound such as ALERT, and avoid a nasty popup warning to the user. I do not want to open another window. This has to be simple as that's why I chose this mehtod.

This code below works fine, it just has the unnecessary CANCEL button. Displaying both OK and CANCEL does not make any sense for what I want. Actually, I'd also prefer an EXIT button but the OK button is okay. But the main point of this question is the CANCEL button.

Or can you give me better imroved code to do what I need?

<script language="JavaScript">
<!--
function javascript_lucky_help() {
	
var message = "Message goes here.";
 
  var return_value = confirm(message);
  if (return_value == true) {
	}
}
 
// -->
</script>
 
 
<div onclick="javascript_lucky_help()">
<input type="button" value="How This Works" />
</div>

Open in new window

JanrowAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LordOfPortsCommented:
It is unfortunately not possible to customize the built-in confirm prompt and since you do not want to use alert or open a new window one other technique would be to use a fixed, initially invisible DIV that would be shows on click by switching its class. Here is one example where by a screenshot of an empty MessageBox which you can create in any development environment or custom draw an image is used as the background for a DIV and it is made visible on click.

Simply save the HTML code as test.html and the image as customconfirm.png in the same directory to see the example of this technique.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Custom Confirm</title>
    
    <style type="text/css">
        
        .CVisible
        {
            display: block;
            position: absolute;
            top:30%;
            left:40%;
            width:200px;
            height:126px;
            background-image:url('customconfirm.png');
        }
        
        .CInvisible
        {
            display:none;
        }
        
        #divMessage
        {
            position: absolute;
            top:32%;
            left:30%;
            font-size:12px;
        }
    
    </style>
</head>
<body>
<script type="text/javascript" language="JavaScript">
// <!--
 
function javascript_lucky_help() 
{ 
    document.getElementById('divCustomConfirm').className = "CVisible";
}
 
// -->
</script>
 
 
<div onclick="javascript_lucky_help()">
<input type="button" value="How This Works" />
</div>
<div id="divCustomConfirm" class="CInvisible" onclick="this.className='CInvisible';">
 <div id="divMessage">Message goes here.</div>
</div>
</body>
</html>

Open in new window

customconfirm.png
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
scrathcyboyCommented:
Even in a subwindow, you cannot get rid of the square - bar to minimize, and X to close window.  If you could, there would be no way for the user to get rid of the window.
0
JanrowAuthor Commented:
Yes, that gives me plenty of options and I believe will let me do what I want. Thanks so much!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.