Thursday, 23 May 2019

Embedding iframe when page scrolls

I am trying to add an iframe which consist of form . I am inserting this ifram e when the page is loaded already and scrolled at some position ,I have used jquery this script is working fine it appending that script tag under that div but the thing it should load iframe at that place. please help out

$(document).ready(function() {
  var element_position = $('#Banner').offset().top;

  $(window).on('scroll', function() {
    var y_scroll_pos = window.pageYOffset;
    var scroll_pos_test = element_position;

    if (y_scroll_pos > scroll_pos_test) {
      //do stuff
      $('#form1').append('<script src= "http://www.samisite.com/test-csb2nf/ifform/ssform.php"><script>);
    }
  });
});
<div id="#Banner"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="form-in">
  <script id="form1"></script>


from Embedding iframe when page scrolls

No comments:

Post a Comment