Reputation: 1603
Say I have an anchor link like:
<a id="page-contact" rel="shadowbox;width=640;height=400" href="/contact.php">link here</a>
How would I be able to open it from jquery i.e.
jQuery('#page-contact').click();
Obviously that calls the .click event but doesn't do the href if that makes sense.
The object of this is to actually open a lightbox not to change the page like window.location
Upvotes: 3
Views: 6434
Reputation: 1603
Beat the geeks again!
I've done this and it works! :-)
Shadowbox.open({
content: '/content.php',
type: 'iframe',
title: 'Tags',
height:350,
width:450
});
Upvotes: 0
Reputation: 340055
To change your current page to the href
attribute of that element:
document.location.href = $('#page-contact').attr('href');
EDIT now that we have the real question, I think you can do this:
var obj = Shadowbox.setup('#page-contact');
Shadowbox.open(obj);
Upvotes: 2
Reputation: 149804
Use either one of these to trigger a click
event:
$('#page-contact').click();
Or…
$('#page-contact').trigger('click');
If you’ve initialized the Shadowbox plugin correctly, the triggered click will cause the lightbox to appear.
Upvotes: 0
Reputation: 1679
if you want to trigger a click event on a jquery selection use:
('#page-contact').trigger('click')
Upvotes: 0
Reputation: 236202
If you want to redirect the browser window to that target (specified in the href
attribute) do this:
window.location.href = $('#page-contact').attr('href');
Upvotes: 1