What is the "On Failure" Technique?

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered
What is the "On Failure" Technique?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,064 Points 20k badge 2x thumb

Posted 2 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,064 Points 20k badge 2x thumb
This one isn't mine but I give the guy who came up with it credit. In this article the author (Nathan Thompson of WEG) creates two user defined variables [of] and [/of] which act almost identically to the image onload technique user defined variables [iol] and [/iol].

Tabs in QuickBase
https://azastudio.net/consulting-1/2016/12/26/creating-tabs-in-quickbase

Rather than load an image the on failure technique uses an <img> tag but leaves the src attribute empty thus causing an error. The onerror attribute then executes JavaScript that loads the user defined pages containing the custom JavaScript.

So this technique might be faster than my image onload technique because no image is fetched. Pretty clever if you ask me. The only improvement I could make to this technique is to remove the "javacript:" label within the onerror attribute. This fragment of the code (ie "javascript:") was introduced in error on an earlier version of the image onload technique but is not needed (I silently removed it).
Photo of Nathan

Nathan

  • 60 Points
Thank you Dan, good catch, I left that tag accidentally.