Hello Community,
does anyone has a java script example for subscription center?
When the contact clicks "do not email" all subscription lists should be deactivated!
Thank you!
Best Regards
Jennifer
Hi Jennifer,
We should put the script on marketing page.
From my using experience, I always put it after end tag of body element.(And the script should be nested in script tag.)
--- How do I proceed when we host it externally via iframe?
I am not so clear about what does "host it externally via iframe" mean.
Could you share me more details about it?
As per my understanding, do you mean the form is being hosted on an external website such as Wordpress?
If so, as far as I know, some WP plugins might create an iframe element on page and custom elements would be put to the iframe.
To handle such situation, we could:
> If custom elements were actually put to iframe, then we need to paste form embedding script to web page directly without using plugin.
> If iframe is actually another web page, then we should put the script to that corresponding page.
In a word, elements in iframe couldn't be accessed.(A more accurate statement is that we couldn't inject javascript into iframe.)
Please kindly point out if I had misunderstood towards your question.
Regards,
Clofly
Thank you very much!
And where do i have to put this script? in the marketing form or in the standard marketing page?
I use the standard subscription center?
How do i proceed when we host it externally via iframe?
Hi Jennifer,
As per my understanding, you could try code below, run it at "afterFormLoad" event of marketing form.
1. Get id value of "Do not email" input field and subscription lists in HTML mode of marketing page.
We can find that "Do not email" element block is named as "data-editorblocktype="Field-checkbox"" and subscription list element block is named as "data-editorblocktype="SubscriptionListBlock"" by system.
2. At change event of "Do not email", check whether the checked property of "Do not email" equals to true,
if yes, uncheck other checkbox fields.
MsCrmMkt.MsCrmFormLoader.on('afterFormLoad', function () {
document.getElementById("bddafd65-310b-4d51-91b4-d251a5002add").addEventListener('change', function () {
if (this.checked === true) {
document.getElementById("66021523-07dd-ea11-a813-000d3aa08990").checked = false;
document.getElementById("6c80c140-dfe1-ea11-a813-000d3aa08990").checked = false;
}
})
});
If I checked the "Do not email", then all subscription lists will be unchecked.
Regards,
Clofly
André Arnaud de Cal...
292,074
Super User 2025 Season 1
Martin Dráb
230,900
Most Valuable Professional
nmaenpaa
101,156