Trigger popup from anchor tag in URL
-
On my site, there is a popup section in the footer with the CSS id ‘contact’. That section has a contact form and a code module with my javascript. The popup can be viewed on the site I’m building at the moment at badd.ie. If you click “Contact” in the footer menu, you can see that the section is revealed as expected.
What I’m trying to do is automatically launch that popup if someone clicks an external link to the site that includes #contact in the URL eg
badd.ie/#contact
. Something similar to the effect produced by this post but using a page anchor instead of a URL parameter.The Javascript I’m using is…
jQuery(document).ready(function() { DiviArea.addAction( 'ready', function() { if ($(location).attr('hash') == "#contact") { DiviArea.show('contact'); } }); });
From what I understand, it registers a function to execute when DiviArea initialises. That function then checks to see if
#contact
exists in the URL and then if it does it shows the popup. To be on the safe side, I also put that code inside a jQuery document.ready function but I still get that error in my console. The fact I get the error means the function was registered successfully, executed, and the page anchor was found in the URL.Whatever I do, it seems to be trying to execute
DiviArea.show('contact');
before the section is available in the DOM. But… it must be in the DOM because the javascript is located within that section. Its all very confusing.The page I need help with: [log in to see the link]
- The topic ‘Trigger popup from anchor tag in URL’ is closed to new replies.