I searched, but couldn't find anything.
I have a sticky header that shows up on the page after scrolling down on the page. This was working wonderfully on the page. However, I now have to unfortunately have to put it within an iframe.
I have to same exact code, but I believe it's the window.scroll that is causing it to trip up. The content is just sitting at the top of the page behind everything and when inspecting the code it stops at that function and goes no further.
Is there an alternative to window.scroll (or scroll function) or is there a way to make it work within an iframe? All my attempts have failed.
My example is here https://www.bootply.com/edHiY15iJy#
My HTML for the header
<div class="container">
<header class="header-wrapper">
<div class="sticky-header">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label class="bold">Customer Name: </label>
<label>Person!! </label>
</div>
<div class="form-group">
<label class="bold">Address: </label>
<label>101 Main Street </label>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="bold">Email:</label>
<label>something@email.com </label>
</div>
<div class="form-group">
<label class="bold">City, State:</label>
<label>Tavierner, FL </label>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="bold">Phone:</label>
<label>555-555-5555 </label>
</div>
<div class="form-group">
<label class="bold">Club Code:</label>
<label>456 </label>
<label class="bold">Associate#:</label>
<label>45 </label>
</div>
</div>
</div>
</div>
</header>
<section>
<p>this</p><p>this</p><p>this</p><p>this</p><p>this</p>
<p>this</p><p>this</p><p>this</p><p>this</p><p>this</p>
<p>this</p><p>this</p><p>this</p><p>this</p><p>this</p>
<p>this</p><p>this</p><p>this</p><p>this</p><p>this</p>
<p>this</p><p>this</p><p>this</p><p>this</p><p>this</p>
<p>this</p><p>this</p><p>this</p><p>this</p><p>this</p>
<p>this</p><p>this</p><p>this</p><p>this</p><p>this</p>
<p>this</p><p>this</p><p>this</p><p>this</p><p>this</p>
<p>this</p><p>this</p><p>this</p><p>this</p><p>this</p>
<p>this</p><p>this</p><p>this</p><p>this</p><p>this</p>
<p>this</p><p>this</p><p>this</p><p>this</p><p>this</p>
<p>this</p><p>this</p><p>this</p><p>this</p><p>this</p>
<p>this</p><p>this</p><p>this</p><p>this</p><p>this</p>
</section>
</div>
and my jquery
if ($('.sticky-header').length >= 1) {
$(window).scroll(function () {
var header = $(document).scrollTop();
var headerHeight = $('.header-wrapper').height();
if (header > headerHeight) {
$('.sticky-header').addClass('sticky');
$('.sticky-header').fadeIn();
} else {
$('.sticky-header').removeClass('sticky');
}
});
}
A screenshot of what the menu looks like when it's not working: