Created
April 2, 2014 14:16
-
-
Save taf2/9935072 to your computer and use it in GitHub Desktop.
number replacement with custom formatting examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// insert code here: https://calltrackingmetrics.com/accounts/tracking_script_settings | |
window.CTMSourceEvent = function(event) { | |
if(event.state=='after') { | |
// generic solution to replace a number format for a given element after our code runs e.g. after event. | |
document.getElementById("the-phone").innerHTML = "Insert Your Custom Number Format"; | |
} | |
if (event.state == 'node:after') { | |
// more fine grained control of replacement you have access to the exact DOM Element we've located a number and replaced. | |
if (event.node.innerHTML.match(/Your number digits to match/)) { | |
event.node.innerHTML = event.node.innerHTML.replace(/replace our formatting/,"with your formatting"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment