views:

598

answers:

1

Hello,

This 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

A: 

a) you can put other items inside an a tag, it will work but it's unsemantic.

b)

  1. put your iframe in a hidden div (or ajax it in on click)
  2. 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

Haroldo
Hello,Could you please elaborate on your point b)1. "Ajax it on click".
Tim
Also, I am not sure how well this will work as I have to load several external content urls, from the one page.
Tim
rather than have all these hidden iframes about wasting load time, you can load one at a time in on demand with ajax.
Haroldo