_anomDiebolt_
7 years agoQrew Elite
Introducing the Three Quotes and a Script Technique (3Q&S)
Introducing the Three Quotes and a Script Technique (3Q&S)
I though I would provide some usage notes on the newly named technique Three Quotes and a Script (3Q&S). In a nutshell this is just a variant on the IOL and EOH techniques where you don't reference a code page. Rather all the relevant script is embedded into an onclick or onerror handler using some clever use of three different quote characters that don't make the embedded script unreadable with various HTML escaping mechanisms.
Here is a prototype button using the 3Q&S technique:
use the same 3Q&S technique along with the OEH technique:
(1) run some type of script that modifies the page's appearance or behavior
(2) produce displayable content in the <td> cell where the <img> field is located. In this case within the script you explicit assign the outerHTML property of the <img>:
One final note is that despite how wonky this method may appear it has some attractiveness as a workaround since the formulas are self contained. A more formal method of introducing script using the IOL or OEH techniques requires you to create (1) a formula named [-], (2) two user variables named [iol] and [/iol] and (3) a code page named module.js. Some users find it conceptually simpler to just add a single formula no matter how strange it may look. Using the three different quotes with the 3Q&S technique keeps the formula readable (at least on data entry - QuickBase munges the formula after saving it).
I though I would provide some usage notes on the newly named technique Three Quotes and a Script (3Q&S). In a nutshell this is just a variant on the IOL and EOH techniques where you don't reference a code page. Rather all the relevant script is embedded into an onclick or onerror handler using some clever use of three different quote characters that don't make the embedded script unreadable with various HTML escaping mechanisms.
Here is a prototype button using the 3Q&S technique:
"<a href='#' class='Vibrant Success' onclick='Pass simple field values using data attributes and within your JavaScript read these values as text using this.dataset.*. Simple fields values mean text fields or numbers. The text fields you pass as data attributes should not contain single or double quotes so it is best to only pass text fields that are names or identifiers such as "SKU1002". Passing numeric fields is okay but withing the script they will be read as text values. Passing other fields such as email, dates and phone numbers is probably okay but addresses and multi-line text fields could be problematic. In these cases is might be simpler to pass the [Record ID#] alone and gain access to all the field values within the script by calling API_GetRecordInfo.
// your script here
// write you JavaScript without using single or double quotes
// instead use backtick quotes (with or without string interpolation)
'>Button</a>"
"<a " &If you need your script to run immediately upon page load you can
"data-rid='" & [Record ID#] & "' " &
"data-name='" & [Name] & "' " &
"data-number='" & [Number] & "' " &
"href='#' class='Vibrant Success' onclick='
// your script here
// access field values using the this.dataset.* construct
// this.dataset.rid
// this.dataset.name
// this.dataset.number
'>Button</a>"
use the same 3Q&S technique along with the OEH technique:
"<img src onerror='Again, if you need to pass fields values to your script use data attributes:
// your script here
// write you JavaScript without using single or double quotes
// instead use backtick quotes (with or without string interpolation)
'>"
"<img "In the case of the OEH technique there are two general use cases:
"data-rid='" & [Record ID#] & "' " &
"data-name='" & [Name] & "' " &
"data-number='" & [Number] & "' " &
"src onerror='
// your script here
// write you JavaScript without using single or double quotes
// instead use backtick quotes (with or without string interpolation)
// access field values using the this.dataset.* construct
// this.dataset.rid
// this.dataset.name
// this.dataset.number
'>"
(1) run some type of script that modifies the page's appearance or behavior
(2) produce displayable content in the <td> cell where the <img> field is located. In this case within the script you explicit assign the outerHTML property of the <img>:
this.outerHTML= <content to be displayed>;This content can include arbitrary HTML without restrictions.
One final note is that despite how wonky this method may appear it has some attractiveness as a workaround since the formulas are self contained. A more formal method of introducing script using the IOL or OEH techniques requires you to create (1) a formula named [-], (2) two user variables named [iol] and [/iol] and (3) a code page named module.js. Some users find it conceptually simpler to just add a single formula no matter how strange it may look. Using the three different quotes with the 3Q&S technique keeps the formula readable (at least on data entry - QuickBase munges the formula after saving it).