I use an external consent tool on my webseite (inmobi choice). The tool is loaded with an async javascript and opens a window on my website to ask for consent.
Is it somehow possible to change text with javascript or jquery in this javascript generated consent tool window?
I am able to change texts in my local website for example with
document.getElementsByClassName("myClass")[0].innerHTML = 'new text';
or
$(".myClass").text('new text');
But that does not work in the javascript generated window of the consent tool.
The javascript window of the consent tool looks like this
<div class="qc-cmp2-container" id="qc-cmp2-container" data-nosnippet="">
<div class="qc-cmp2-main" id="qc-cmp2-main" data-nosnippet="">
<div id="qc-cmp2-ui" role="dialog" aria-label="qc-cmp2-ui">
[...]
<div class="qc-cmp2-consent-info">
Text to be changed...
<div>
<div>
<div>
<div>
With
console.log(document.getElementsByClassName("qc-cmp2-consent-info"));
I can see the text in the console, but was not sucessfull to change it.
HTML Collection []{
0: div.qc-cmp2-consent-info
1: {scrollfalse: f}
...
innerHTML: "Text to be changed..."
For example
$(".qc-cmp2-consent-info").text('new text'); shows no change
-
Is the consent HTML content injected as an iframe?FiddlingAway– FiddlingAway2024年02月18日 13:48:49 +00:00Commented Feb 18, 2024 at 13:48
1 Answer 1
Have you tried using $(".qc-cmp2-consent-info").val('new text'); ?
1 Comment
$(".qc-cmp2-consent-info").val('new text'); does not change the text in the consent window.Explore related questions
See similar questions with these tags.