Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. How come javascript onfocus and onblur events do not fire in IE more then once?

How come javascript onfocus and onblur events do not fire in IE more then once?

Scheduled Pinned Locked Moved Web Development
javascripttutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rgordon99
    wrote on last edited by
    #1

    Could someone tell me why the onfocus and onblur events only fire once. For example, using the code below, when you bring IE to the foreground the onfocus event fires and when you click on another windows (outside of that instance of IE) the onblur event fires, very good. But I can not get it to fire again, unless I reload the code. I expected these events to keep firing for each time the browser gets and loses focus. Is there something I'm missing or is that just a limitation of IE v7? Here is a sample test: function lostfocus() { document.write("lostfocus\n") } function gotfocus() { document.write("gotfocus\n") } Thanks... Rick

    D 1 Reply Last reply
    0
    • R rgordon99

      Could someone tell me why the onfocus and onblur events only fire once. For example, using the code below, when you bring IE to the foreground the onfocus event fires and when you click on another windows (outside of that instance of IE) the onblur event fires, very good. But I can not get it to fire again, unless I reload the code. I expected these events to keep firing for each time the browser gets and loses focus. Is there something I'm missing or is that just a limitation of IE v7? Here is a sample test: function lostfocus() { document.write("lostfocus\n") } function gotfocus() { document.write("gotfocus\n") } Thanks... Rick

      D Offline
      D Offline
      daveyerwin
      wrote on last edited by
      #2

      here's a better example function lostfocus() { document.getElementById("displayFocus").innerHTML = "lostfocus\n"; } function gotfocus() { document.getElementById("displayFocus").innerHTML = "gotfocus\n"; }

      your problem was your use of document.write

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups