-4

Possible Duplicate:
Changing the way a JavaScript Alert() or Prompt() looks

I have a string in my JavaScript code here:

_msg = "You have errors on Question Number: " + _qid + "\n";

I am displaying _msg using alert.

How can I make it bold?

Community
  • 1
  • 1
user1181690
  • 1,443
  • 2
  • 11
  • 12
  • Based on you question: **You want to make a string variable bold**... You can't. you can do zoom in, but that's the best you can! **lol** – gdoron Feb 05 '12 at 02:39
  • 1
    This is your guide: https://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx – Sparky Feb 05 '12 at 02:41
  • No not the variable, What I mean is that when I display this string on screen, I want it to display the string in bold font, so is there a way to do this? – user1181690 Feb 05 '12 at 02:41
  • _msg is displayed in an alert, I want the _msg in the alert to be bold – user1181690 Feb 05 '12 at 02:43

3 Answers3

2

Your answer is way too vague to know what you're actually doing with that string, but in the off chance you're just sticking it in the DOM somewhere:

_msg = "<b>You have errors on Question Number: " + _qid + "</b>\n";

Edit: You're displaying it in an alert, sorry there isn't any control over the formatting in that case.

speshak
  • 2,457
  • 3
  • 27
  • 34
1

You can't style HTML content in alert pop-ups.

Your best bet is looking into a custom pop-up, which you can style with CSS and toggle with Jquery.

This tutorial is fairly simple as it only requires the Jquery library:

http://webdesignersdesk.com/2010/05/create-custom-popup-model-window-with-jquery/

There are also several plugins available for custom pop-ups too.

skippr
  • 2,656
  • 3
  • 24
  • 39
0

You cannot bold text in an alert. Sorry.

However, you can add something in the DOM that looks like an alert.

icktoofay
  • 126,289
  • 21
  • 250
  • 231