Home > Sniplets > What happened to Alert and Confirm?

What happened to Alert and Confirm?

We’ve all been on Web sites and received the “Invalid input, please try again” alert and the “Delete record. Are you sure?” confirmation dialog. Developers often want to pop up informational messages like these.

Sidebar, however, has disabled these JavaScript functions. Using popup dialogs goes against the Windows Vista UX guidelines for Sidebar gadgets. If you still feel compelled to use popups, you can emulate these functions.

To do this, first insert a simple one line tag into the head element of your HTML:

<script src="alert.vbs" type="text/vbscript"></script>

Then create a file that contains the following code and name it alert.vbs. Now you can continue to use alert and confirm as you wish.

‘simulate JavaScript alert() function
sub alert(prompt)
      MsgBox prompt, 48 , "Sidebar Gadget"
end sub  

‘simulate JavaScript confirm() function
function confirm(prompt)
      dim res
      res = MsgBox (prompt, 33, "Sidebar Gadget")
      if res=1 then
          confirm = true
      else
          confirm = false
      end if
end function


via Gadgets: Build Your Own Windows Vista Sidebar Gadget.


  1. Juli 6th, 2009 at 14:32 | #1

    Today I found another way to get javascript popup in sidebar on Andreas Rynes’ Two Cents Blog:

     

    Have you ever tried to use an javascript Alert in your Sidebar Gadget?

    It won’t work…you’ll have to use a little trick to make that work. I do advise you not to use it in your deployed version, but it makes sense for some sort of debugging or testing

    You can use ActiveX and WScript.Shell object to create popups:

    var objShell = new ActiveXObject(“WScript.Shell”);

    objShell.Popup(“This is a popup from Sidebar”);

     

  1. No trackbacks yet.

:) :( :biggrin: :D :lol2: :DD ;) ;( :roll: :motzen: :sauer: :wut: :rosi: :bye: :ok: :down: :hmm: :devil: :angel: :happy: :haemisch: 8) :idee: :nono: :wall: :wuerg: :angst: :nick: :kopfsch: :poeh: :flirt: :herzaugen: :stolz: :fragend: :stoned: :bad: :ball: :baseball: :erschrecken: :ohnmacht: :flowers: :foermchen: :nana: :lange_nase: :hacken: :arsch: :ooom: :naegel: :oldman: :party: :rauchen: :schimpf: :stirnpatsch: :tel: :vogelzeig: :pfeifen: :schulterzuck: :schweiz: :-o :sorry: :stricken: :waschen: :tauben: :schreiben: :yes: :zaehne: :zeitung: :girlfight: :zieh: :bunny: :anbet: :beat_horse: :applaus: :auslach: :baeaeh: :gaehn: :kopfkratz: :kopfweh: :papst: :psst: :stinkefinger: :zensur: :red: :peitsche: :schlafen_gehen: :vampirshrek: :fein: :drunk: :eat_fast: :hungry: :poppen: :wangenkuss: :sabber: :beten: :beisstischkante: :klo_besetzt: :haengematte: :chuckle: :reiten: :gfightsmiley: :schwuchtel: