- This topic is empty.
-
AuthorPosts
-
March 18, 2010 at 9:45 am #10129haroldoParticipant
a) you can put other items inside an a tag, it will work but it’s unsemantic.
b)
- put your iframe in a hidden div (or ajax it in on click)
- the do $(‘.menuitem’).click(hiddendiv.fancyb…().show())
Personally i would always avoid using onclick=”” it’s much easier to maintain your code in an external js file
March 18, 2010 at 12:07 pm #10127timParticipantThis question seems to have been asked a lot, but I haven’t seen an answer that works.
So I have a div that works like this:
<div onclick="location.href='http://www.abc123.com';" class="menuitem"> </div>
Now I need the link (specified in location.href) to open up in a fancybox iframe.
I would love to use an A element but this Div holds other items so I don’t think I can.
I am open to all suggestions… even using elements other than divs, or using a different jquery iframe lightbox.
Thanks
Tim Mohr
July 4, 2012 at 3:49 am #10128pythonian29033ParticipantI was doing the same thing and wanted to invoke fancybox dynamically also
I know it might not be ideal, but this is what i did (I use jquery btw):JS:
jQuery(document).ready(function($){ $(".fancybox").fancybox(); $("form").submit(function(){ $(".fancybox").trigger("click"); return false; }); });
HTML:
<a href="#div_id" class="fancybox"></a> <div style="display:none;"> <div id="div_id"> This will show up in my fancybox </div> </div>
it’s a quicker easier way; I found, hope it helps someone!
happy coding!October 17, 2012 at 6:47 am #10130ronaldParticipantThis demonstrates how to use fancybox without requiring the
<a href>
link element.Inline (1.3.4):
<div id="menuitem" class="menuitem"></div> <div style="display:none;"> <div id="dialogContent"> </div> </div> $('#menuitem').click(function() { $.fancybox({ 'type': 'inline', 'content': '#dialogContent' }); });
Inline (2.1.5):
<div id="menuitem" class="menuitem"></div> <div style="display:none;"> <div id="dialogContent"> </div> </div> $('#menuitem').click(function() { $.fancybox({ 'type': 'inline', 'href': '#dialogContent' }); });
Iframe:
<div id="menuitem" class="menuitem"></div> $('#menuitem').click(function () { $.fancybox({ type: 'iframe', href: 'http://www.abc123.com' }); });
-
AuthorPosts
- You must be logged in to reply to this topic.