SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    custom made alternative to "alert()"

    Hey folks,
    although I'm pretty much noob, I was wandering how would I make my own version of "alert()", or prompt(). I see jquery (i think) has something like this. But I'd like to make it myself, for the perpuse of getting experince. So, first problem is, I'm not sure how would I temporary "lock background", so that when your own alert shows, you must select ok. Is there maybe any function in JS that allows this (to lock temporary website expect certain elements (which would be div in this example, that would contain my alert box) or in other words, make site unavailable to you until you press OK button on your custom made alert (div element or something) message)?
    tnx.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,604
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    See http://javascript.about.com/library/blmodald1.htm for an example of how to do it.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello, it's me again!
    Well, I have another problem. I have this "library" called UI, and there is function called "Ui.alert", that takes text as argument. I'm trying to achive, that when you will call from other file, like test.js this function, like Ui.alert("insert random text"); that it would display my custom alert box. I have create SPAN element with this message, but the problem is that I don't know where do append this span element in order to display it. Since I'd like to call this function when necesary, I don't have any idea where to append it. I tryed to append it to body tag, but it does seems to work. Any ideas?

  4. #4
    Google Engineer polvero's Avatar
    Join Date
    Oct 2003
    Location
    Mountain View
    Posts
    567
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey folks,
    although I'm pretty much noob, I was wandering how would I make my own version of "alert()", or prompt(). I see jquery (i think) has something like this. But I'd like to make it myself,
    I have this "library" called UI,
    I thought you were trying to do this yourself? Nevertheless, did you try:
    Code:
    document.body.appendChild(mySpanElement);

  5. #5
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    tnx, I'll try!
    "I thought you were trying to do this yourself? Nevertheless, did you try":
    well this UI library is my. I'd like to have library that would have several functions like this custom alert box.

    ---edited---
    oh, it works, tnx a lot man!

  6. #6
    Google Engineer polvero's Avatar
    Join Date
    Oct 2003
    Location
    Mountain View
    Posts
    567
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sweet!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •