Add back-link to modal pop-up

Here's the Jquery and Css to for the back link

/*Modal back history link*/
$(document).on('knack-scene-render.any',   function(page) {
  $('<span class="modal-back-link">back</span>').insertBefore('#kn-modal-bg-0 > div > h1 > span');

});

(document).on('knack-scene-render.any', function(event,page){ (’#kn-modal-bg-0 > div > h1 > span.modal-back-link’).click(function(){
parent.history.back();
return false;
});
});

/* modal back-link*/

.modal-back-link {
display: block;
cursor: pointer;
position: absolute;
right: 80px;
top: 0px;
font-size: 14px;
font-weight: normal;
text-decoration: underline;
}

That's awesome thanks!

Thank you for this! I will be using this. I'm also looking for a way to add the crumb trail back to the modal pop-up. If anyone has direction for that, I'm all ears.

Very nice !

Has anyone gotten this to work recently? I can’t seem to get it to work…

Here’s some code that works in 2024 for anyone who stumbles accross this

It adds a back button to modal popup header and also fixes some styling issues

How to restyle modal header & add back button

1 Like