Namespace: Interaction:obfuscatePrivateTelLink

Interaction:obfuscatePrivateTelLink

Methods

Augment a link element to hold an obfuscated private tel link, to be able to contact people via their own phone number, without the need to openly write the number into the DOM permanently, in a way crawlers could identify easily.

The method takes all parts of the number as (hopefully) unidentifiable parameters and then applies them internally, to build a number string with tel protocol dynamically on mouse or focus interaction in the link's href, offering normal link functionality from here on. If the interaction ends, the href is removed again immediately, so the link is only and exclusively readable and complete during user interaction.

You may set the link text yourself or set setAsContent to true, to let the function fill the link text with the completed address. Be aware, that this, although still being obfuscated, lowers the level of security for this solution.

Although most parameters are technically optional, this function still expects secondTelPart or firstTelPart to be filled. While only one part is strictly necessary here: I'd always suggest to use all parts, since, the more of a number is written together, the easier the number can be parsed.

Parameters:
Name Type Attributes Default Description
link HTMLElement

the link to augment, has to be a node where we can set a "href" attribute

setAsContent Boolean <optional>
<nullable>
false

define if the number should be used as link text, being formatted according to DIN 5008 (still uses string obfuscation, but weaker against bot with JS execution)

secondTelPart Number | String <optional>
''

second half of the main number +49 04 123(4-56)<-this; add a dash to signify where a base number ends and the personal part starts

firstTelPart Number | String <optional>
''

first half of the main number +49 04 (123)<-this 4-56

regionPart Number | String <optional>
''

the local part of the number after the country part e.g. +49(04)<-this 1234-56

countryPart Number | String <optional>
''

the country identifier with or without + this->(+49) 04 1234-56 (do not prefix with a local 0!)

Source:
Throws:

error if secondTelPart and firstTelPart are empty

Returns:
the augmented link
Type
HTMLElement
Example
obfuscatePrivateTelLink(document.querySelector('a'), true, 123, 439, 40, '+49');