Я прихожу к вам, потому что меня полностью заблокировали на неделю. Я работаю над сайтом Wordpress с Elementor. Я использую форму Hubspot, загруженную с моим iframe в элементе виджета HTML от Elementor.
Я также использую window.onload для создания анимации на моем ярлыке. Мой window.onload всегда выполняется (я проверяю с console.log, чтобы убедиться), но иногда моя анимация не работает, и я не знаю почему.
Это мой сценарий для загрузки формы hubspot (без идентификатора формы)
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<div id="form-popup-press">
<script>
hbspt.forms.create({
css: '',
portalId: "xxxxxxx",
formId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
target: "#form-popup-press",
});
</script>
</div>
И это мой window.onload.
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script type="text/javascript" async=false>
var doc = document.documentElement;
doc.setAttribute('data-useragent', navigator.userAgent);
window.onload = function () {
$('.hs-fieldtype-select').removeClass("not-focused");
$('.hs-fieldtype-select').addClass("has-focus");
$('form').attr('autocomplete','off');
$('input').attr('autocomplete','off');
$('html[data-useragent*="Chrome"] form').attr('autocomplete','false');
$('html[data-useragent*="Chrome"] form input').attr('autocomplete','false');
$("#form-popup-press .hs-input").focus(function(){
$(this).closest(".hs-form-field").removeClass("not-focused");
$(this).closest(".hs-form-field").addClass("has-focus");
}).blur(function(){
if( !$(this).val() ) { //check to see if the input has a value
$(this).closest(".hs-form-field").removeClass("has-focus");
$(this).closest(".hs-form-field").addClass("not-focused");
} else {
$(this).closest(".hs-form-field").addClass("has-value");
}
})
$("#form-popup-press .hs-input").on("change paste keyup", function() {
if( !$(this).val() ) { //check to see if the input has a value
$(this).closest(".hs-form-field").removeClass("has-value");
}
});
}
</script>
В моей консоли нет ошибок, поэтому я не знаю, где я могу искать. Большое спасибо за вашу помощь :)