I have a “lightbox” plugin installed in my site that I use for my popup windows throughout the site. For one feature of my site I’m doing a cookie check and if one doesn’t exist I have a submit form popup in a window; and I would like to use my plugin for that instead of, for example, a window.open. I just need to add a rel=“lightbox” to my location achieve that. My current script is:
Just to understand you correctly: if your cookie check fails, you would like to have a form open automatically in a modal window (using Lightbox).
Is that correct?
Thanks, I’m actually using a Joomla plugin that handles most everything; images, videos, external sites, HTML, etc. It’s a lightbox effect and the rel can be anything you enter; I just used “lightbox”. I use it in the rest of the site for YouTube videos, images, etc. My form is embedded in a page and I’m popping that up. If I could add rel=“lightbox” I’d be good to go.
Ah, that makes sense why I was unable to insert the rel tag, thanks. And thanks for this trigger option, I’ll be able to get that pulled up here in a little to try out and will report back.
Thanks again, I’ve inserted this option and it worked great and created the lightbox pop just as I needed. One concern is that with the “<a href=“document-download-form.html” rel=“lightbox” id=“link”>Click</a>” being hidden Google will still pick it up. I’ll more with it but am definitely heading in the right direction. Thanks again for your time and help.
Appending the link would be great, I tried it but it just goes to the “document-download-form.html” page with out popping up, it doesn’t trigger the lightbox. I see where you’re heading with that though and will play around with it. It seems though that the lightbox trigger becomes nulled when it’s appended for some reason; I’ll troubleshoot it though to confirm.
The “document-download-form.html” is a hidden page and only should be called when clicking on certain links, which will be some PDF files. I have other coding in the form as well where the file will download once the form is submitted and they go to a specific “thank you” page. If it was picked up by Google and someone went to it it wouldn’t work correctly, doesn’t have a template (it’s the form only), etc.
I’m guessing that this is a plugin issue.
Maybe it grabs all links with a rel attribute of “lightbox” which are present in the DOM on page load and attaches certain behaviour to them.
The bare-bones example I posted should have worked, however.
Hi, great idea with the Google non-indexing. You’re dead on with the plugin issue, there was a conflict with other JQuery code and I was able to fix that using Fancybox instead and the popup is now working using the variable. I have Fancybox using the ID attribute name “formbox”. My current code is below, which is working fine for what I need. I’ll revisit it at a later time to make improvements but I’m good to go for now.
The linked files all ended up being PDF files so I change the click function to files with PDF extensions:
<script type="text/javascript">
jQuery(document).ready(function($) {
$('a[href$=".pdf"]').click(function() { //applies to all PDF files
if ($.cookie("AKHDownload")) { //checks for AKHDownload cookie
return true;
} else {
var link = $('<a style="display:none;" href="document-download-form.html" id="formbox"></a>');
$("body").append(link);
$('#formbox').trigger('click'); //Fancybox ID attribute name "formbox" triggers popup
return false;
}
});
});
</script>