Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Remove CANCEL option from javascript window

Posted on 2008-10-16
3
Medium Priority
?
200 Views
Last Modified: 2011-10-19
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

0
Comment
Question by:Janrow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 19

Accepted Solution

by:
LordOfPorts earned 2000 total points
ID: 22737128
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
 
LVL 44

Expert Comment

by:scrathcyboy
ID: 22737287
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
 

Author Closing Comment

by:Janrow
ID: 31507002
Yes, that gives me plenty of options and I believe will let me do what I want. Thanks so much!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question