Closed (fixed)
Project:
Colorbox
Version:
7.x-1.2
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
5 Oct 2011 at 14:59 UTC
Updated:
26 Oct 2015 at 11:43 UTC
Jump to comment: Most recent
Hi,
How do i open the colorbox on load or on a condition for example open a popup if a cookie is not set.
Thanks,
Comments
Comment #1
knigh7 commentedNever mind
just in case someone else needs it, here is how you can open colorbox using a script
(function ($) { $(document).ready(function(){ $.fn.colorbox({href:'http://www.google.com', open:true, iframe:true, width:500, height:500}); }); }(jQuery));Comment #2
knigh7 commentedComment #3
Anderskj commentedI have used 5 hours now to get something like this to work:
This is placed inside and on the same page is a working link (when clicked):
<a href="/partner-request?&width=243&height=490&iframe=true" class="colorbox-load init-colorbox-load-processed-processed cboxElement" id="popup-form">Become a partner</a>This is the page: http://acmarine.dk/partners-usa (click the "Become a parther link" to see the colorbox).
I don't know how to open the colorbox (same as clicking the link) on page load. Beleive I have now tried "everything". Where do I put the code in #1?
Comment #4
knigh7 commentedHere is my code, it works with Drupal 7, I have placed it just after the body tag
Comment #5
cruze72 commentedI've put the code into my frontpage.tpl.php and #4 works like a charm for me - thanks.
BUT how can i adapt the code to only load once and not every time the page is loaded.
Much appreciated
Comment #6
knigh7 commentedHmm, you can set a cookie to make it run once, what you can do is set a cookie using javascript and do the whole logic in javascript or using php check if the cookie exists, if its not there then write the cookie and then using php echo the javascript code for the popup
Comment #7
mcfilms commentedHere is how someone did one-time only with lightbox. You can probably modify this for colorbox:
http://drupal.org/node/1005658#comment-4838222
Comment #8
pauleh commentedHere's how I did a colorbox popup for a disclaimer note for a specific node with a 'close box' link and a 'close/redirect' link.
1. Created a node specific template (see: http://robmalon.com/drupal-7-0-preprocess-page-templates-theme_hook_sugg...)
2. Above
</head>in html--node--##.tpl.php3. In 'my.html' there are two links
Comment #9
brandonc503 commentedwhat if i dont need by cookie, i just want on page load, click the first image triggering colorbox