First thing first the page where I have the script:
https://www.glansbeton.be/uitvoering/ (the floating button with gratis offerte aanvragen)
this is my script code:
use Joomla\CMS\Factory; $document = Factory::getDocument(); // Add script $Script = " <script>; jQuery(window).scroll(function(){ if (jQuery(this).scrollTop() > 70) { jQuery('.extensionbuy_now').addClass('btn-".$lftrght."'); } else {jQuery('.extensionbuy_now').removeClass('btn-".$lftrght."'); } }); </script>"; if($btn_align == 0) { $CAlign .= '$(document).ready(function(){ $("#buttn").addClass("zero"); });'; } else if($btn_align == 50) { $CAlign .= '$(document).ready(function(){ $("#buttn").addClass("fifty"); });'; } else { $CAlign .= '$(document).ready(function(){ $("#buttn").addClass("hundred"); });'; } if($btn_float == 0) { $CFloat .= '$(document).ready(function(){ $(".extensionbuy_now").addClass("btn_zero"); });'; } else { $CFloat .= '$(document).ready(function(){ $(".extensionbuy_now").addClass("btn_hundred"); });'; } $Script .= '<script type="text/javascript">'; $Script .= $CAlign; $Script .= '</script>'; $Script .= '<script type="text/javascript">'; $Script .= $CFloat; $Script .= '</script>'; If I simply echo the script: echo $Script;
The output is working like it has to be. So my script is good and working. Now I want to place the script outside the body.
$document->addStyleDeclaration($style); This is not working.
Did read a lot, but I don't know how to do this.
Can someone give me some advice?
没有评论:
发表评论