0
<?php if(isset($_SESSION['cnt'])&&($_SESSION['cnt'] == 5) ){  
$_SESSION['cnt'] = 0;
?>
    <script> 
            //$("#fb_login").trigger('click');
    //$('#fb_login').click();
    $("#fb_login").click(function(){ 
        $("#fb_login").colorbox({width:"300px", height:"200px", inline:true, href:"#loginask_iframe"});
    });
    </script>
<?php } ?>
<a href="#" id="fb_login"></a>
<div style='display:none' class="loginask_iframe_container">
<div id="loginask_iframe">
test
</div>
</div>

i can't get the click function to trigger when the $_SESSION['cnt'] == 5.

any ideas what i am doing wrong? thanks

4 Answers 4

2

Is this what you're looking for?

$("#fb_login").trigger('click');
Sign up to request clarification or add additional context in comments.

Comments

1
<script type="text/javascript">
// Here you define the click.
$("#fb_login").click(function(){
    $("#fb_login").colorbox({width:"300px", height:"200px", inline:true, href:"#loginask_iframe"});
});

// Here you call the click.
$("#fb_login").click();
</script>

2 Comments

it worked, just needed to add $(function() { ... });. Thanks. I almost tried your way :)
also, sometimes i need to add $(window).load(function() {} instead of $(function() { ... });
1

This may be a case of the click function being defined before the anchor is created. Try wrapping the click binding in $(document).ready( ...

Comments

1
<script> 
function triggerLoginColorBox() {
    $("#fb_login").colorbox({
        width: "300px",
        height: "200px",
        inline: true,
        href: "#loginask_iframe"
    });
}
$("#fb_login").click(function(){triggerLoginColorBox();});
<?php
if (isset($_SESSION['cnt']) && ($_SESSION['cnt'] == 5) ){
    $_SESSION['cnt'] = 0;
    echo "triggerLoginColorBox();";
}
?>
</script>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.