How to open a lightbox on page load if url equals

2019-09-20 15:53发布

The title pretty much says it. I would like to show a lightbox on page load only if the url is www.example.com/#popup versus www.example.com

If this could be accomplished with google tag manager that would be grand

I've see bits and pieces of this but I'm having trouble piecing it all together.

HTML:

<a href="#" data-featherlight="#mylightbox">Open element in lightbox</a> 
<div id="mylightbox">This div will be opened in a lightbox</div>

1条回答
趁早两清
2楼-- · 2019-09-20 16:34
if (window.location.hash == "#popup") {
    $.featherlight("#mylightbox");                   
}

See https://github.com/noelboss/featherlight/#manual-calling-of-featherlight

Fiddle Shows manual lightbox open call. http://jsfiddle.net/fm9wp96r/

查看更多
登录 后发表回答