Reputation: 49422
I am trying to add an onclick
code to some JavaScript for some shadowbox.
Here is the code:
Shadowbox.open({
content: 'my.php',
player: "iframe",
title: '<div><a href="#" rel="shadowbox" onclick="Shadowbox.open({ content: \'page2.php\', width: 460, height: 270, player:\'iframe\' }); return false;"></a></div>',
height: 800,
width: 1024,
});
Latest I've tried:
$(document).ready(function() {
$("#mydiv").on("click", "#sb-title", function(){
Shadowbox.open({
content: 'somepage.php',
width: 460,
height: 270,
player:'iframe'
});
});
});
...then...
Shadowbox.open({
content: 'someotherpage.php',
player: "iframe",
title: '<div><a id="mydiv" href="#">Clickme</a></div>',
height: 800,
width: 1024,
});
The above is doing nothing.
For some reason the onclick
is not happening ... is this a syntax issue with the quotes?
How can I fix this?
Upvotes: 1
Views: 459
Reputation: 6742
Try to add just normal text as a title (do not add onclick
).
Then you may add some script to track clicks:
$("body").on("click", "#sb-title", function(){
Shadowbox.open({
content: 'page2.php',
width: 460,
height: 270,
player:'iframe' }
})
EDIT
From your code:
$(document).ready(function() {
//you may try '#sb-wrapper' instead of 'body'
$("body").on("click", "#sb-title", function(){
Shadowbox.open({
content: 'somepage.php',
width: 460,
height: 270,
player:'iframe'
});
});
});
...then...
Shadowbox.open({
content: 'someotherpage.php',
player: "iframe",
title: 'Clickme',
height: 800,
width: 1024,
});
Upvotes: 0