admin管理员组文章数量:1415664
I have a page that displays restaurant food menu. And when a person clicks on a particular food item I want to open the link in colorbox. Is there a way I can open the links in colorbox without effecting other anchor tags. I cannot modify the existing code(menu is displayed by 3rd party plugin) but I can add additional script to the page(jquery or php). So I was hoping to add ("a").click(), but I wasn't sure how to get the href link for a particular anchor tag. For now all the links I want to open have string "/restaurants/" in mon. Any suggestions about how to solve this problem?
I have a page that displays restaurant food menu. And when a person clicks on a particular food item I want to open the link in colorbox. Is there a way I can open the links in colorbox without effecting other anchor tags. I cannot modify the existing code(menu is displayed by 3rd party plugin) but I can add additional script to the page(jquery or php). So I was hoping to add ("a").click(), but I wasn't sure how to get the href link for a particular anchor tag. For now all the links I want to open have string "/restaurants/" in mon. Any suggestions about how to solve this problem?
Share Improve this question asked Jan 19, 2012 at 21:02 user899893user899893 3073 gold badges8 silver badges16 bronze badges 3- Try IFrames which you can make them look better and you can open them as you need it. – coder Commented Jan 19, 2012 at 21:04
- I think this is what you need stackoverflow./questions/1383304/… – coder Commented Jan 19, 2012 at 21:26
- @DotNetter - both questions are colorbox related, but they're different questions. He just wants to add an on click event, and the question you linked to was about auto firing colorbox when visiting a certain url – Tom Commented Jan 19, 2012 at 21:39
1 Answer
Reset to default 2<script type="text/javascript">
$(document).ready(function() {
$("a", ".rest-menuitem").click(
function(event) {
event.preventDefault();
var elementURL = $(this).attr("href");
$.colorbox({iframe: true, href: elementURL, innerWidth: 645, innerHeight: 509});
});
});
</script>
Change innerWidth and innerHeight to fit your content
本文标签: javascriptopen url in jquery colorboxlightboxStack Overflow
版权声明:本文标题:javascript - open url in jquery colorboxlightbox - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745235117a2649000.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论