Link to home
Start Free TrialLog in
Avatar of Nitinol
Nitinol

asked on

Bold alert box text..... how?

Is there a way, and I have seen it done before, to make the text of an alert box, bold or italic?

I have seen it done before and used to know how to do it, but could someone pleae refresh my memory?
Avatar of mbeckman
mbeckman

As far as I know...this is impossible to do with JavaScript.  The reason is because Windows (or your associated OS) has control over the look over OS components (which the alert box is a member of).  I've never seen an alert with bold or italic text.  Sometimes people create  _images_  that are made to look like alert boxes where they have edited it to their pleasure.

- Matt
try a modal dialog
<script>
var AlertBox = window.showModelessDialog("Alert.htm","",'dialogWidth:20; dialogHeight:10; status:0; help:0');
</script>

in Alert.htm have

<body bgColor="grey">
<center>
<b>Alert</b><p>
You are warned!
</center>

sorry I meant

<script>
var AlertBox = window.showModalDialog("Alert.htm","",'dialogWidth:20; dialogHeight:10; status:0; help:0');
</script>

in Alert.htm have

<body bgColor="grey">
<center>
<b>Alert</b><p>
You are warned!
</center>
</body>


hi there,

try out this code i wrote:

<html>
<head>
    <title>Untitled</title>
</head>

<body>
<style>
#myAlert{
    position:absolute;
    top:250px;
    left:250px;
    background-color:silver;
    display:none;
    width:250px;
    height:75px;
    }
#AlertTitle{
    color:white;
    font-size:12px;
    font-weight:bold;
    width:100%;
}
#table1{
    border: 2px outset;
    width:100%;
    }
#AlertContent{
    color:black;
    font-size:12px;
    width:100%;
    }
#OKButton{
    padding:3px;
    font-size:10px;
    background-color:silver;
    }
</style>

<script>
function centerObject( obj ){

//      var left = window.screen.availWidth/2 - obj.style.width/2;
//      var top = window.screen.availHeight/2 - obj.style.height/2;
      var top = window.screen.width/4 - obj.style.width;
      var left = window.screen.height/4 - obj.style.height;
      obj.style.left = left;
      obj.style.top = top;
      }

function swapAlert(){
    var target = document.getElementById('MyAlert');
    var button = document.getElementById('switchButton');
    centerObject(target);
     if ( target.style.display== 'block'){
         target.style.display= 'none';
         button.value='Show Alert';
         return;
         }
    else{
         target.style.display= 'block';
         button.value='Hide Alert';
         return;
    }    
}

</script>

<span id='MyAlert'>
    <table id='table1' cellpadding="0" cellpadding="0">
         <tr bgcolor="#00006A">
              <td id='AlertTitle' width="100%">&nbsp;Alert Title</td>
         </tr>
         <tr>
              <td id='AlertContent' width="100%"><b>Alert Context goes here.</b></td>
         </tr>
         <tr>
              <td id='AlertContent' width="100%"><br><center><input id='OKButton' onclick='swapAlert()'  type='button' value='&nbsp;&nbsp;OK&nbsp;&nbsp;'></center></td>
         </tr>
    </table>
</span>
<br><br>
<input type="Button" id='switchButton' onclick='swapAlert()' value='Show Alert'>
</body>
</html>


Nushi.
Avatar of Nitinol

ASKER

All of your comments were interesting, but I remember it being something really simple...   Maybe I was working with an old browser that actually supported it or something....    Thank you for your responses, but none are what I am looking for....

GwynforWeb - your web dialog comes up, but it is all white, there is not message on it at all.......   it say's web dialog on it, but
there is nothing on the box except for a white background....   Is this what you intended....   The bright green screen though, that was interesting.....

Avatar of Nitinol

ASKER

Nushi, to hide and show an alert box would be too much trouble, and not important enough to do for all the code that went into that.....
There is not need for me to go that far with it....   Especially since I would have to hide the rest of the content on my page to make that alert actually look convincing.....  thank you for your response though, it's much appreciated
>>Especially since I would have to hide the rest of the content on my page to make that alert actually look convincing

you dont need to.
simply set in the style "z-index:100" and it will be the most top.

Nushi.
Avatar of Nitinol

ASKER

ok, thats true....., but still thats too much trouble to go through for an alert box
ASKER CERTIFIED SOLUTION
Avatar of Nushi
Nushi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
we cannot format alter box. It out of control of javascript.
Avatar of Nitinol

ASKER

Thx for trying to help out Nushi, much appreciated
Np.

in here to help as much as i can.

Nushi.