Support » Plugin: jQuery Lightbox » [Plugin: jQuery Lightbox] Show lightbox on page load with Anchor

Viewing 12 replies - 1 through 12 (of 12 total)
  • martinlbb

    (@martinlbb)

    Any ideas ?

    Plugin Author Pedro Lamas

    (@ei99070)

    I’d suggest you guive an ID to the link and use jquery with it!

    <script type="text/javascript">
    $('#my_link_id').click()
    </script>
    martinlbb

    (@martinlbb)

    Following your suggestion, I tried this:
    <a id="les-quais.jpg" name="les-quais.jpg" href="/portfolio/test-photo/les-quais.jpg" title="A Lyon" rel="lightbox[test-photo]" ><img title="Les quais" alt="Les quais" src="/portfolio/test-photo/thumbs/thumbs_les-quais.jpg" width="200" height="133" /></a>

    And then in Javascript (short version, I removed autoload):

    <script type="text/javascript">
    $('#les-quais.jpg').click()
    </script>

    Nothing happened, I just have an error in my console:
    Error: $("#les-quais.jpg") is null.

    martinlbb

    (@martinlbb)

    BTW, jquery is already used in my WordPress blog.

    Plugin Author Pedro Lamas

    (@ei99070)

    My friend, you cannot use that id (with a dot!!!)

    You can use “les-quais-jpg” if you’d like, but the “.” is reserved and cannot/shouldn’t be used in id’s!

    martinlbb

    (@martinlbb)

    Sometimes, I’m too dumb!

    Thanks Pedro for this usefull help!

    BTW, I think I can’t use $, but I have to use jQuery instead of.

    Plugin Author Pedro Lamas

    (@ei99070)

    No problem, and yes, in case of doubt, just use “jQuery()” (case-sensitive!) instead of “$()”

    martinlbb

    (@martinlbb)

    Ok I modified my code.

    <a id="les-quais" name="les-quais" href="/portfolio/test-photo/les-quais.jpg" title="A Lyon" rel="lightbox[test-photo]"  >
    <img title="Les quais" alt="Les quais" src="/portfolio/test-photo/thumbs/thumbs_les-quais.jpg" width="200" height="133" /></a>

    And JS:
    jQuery('#uap').click();

    No error in Console, but nothing show up.
    If I try jQuery('#uap').start(); I get ‘is not a function’.

    From my memory, click is not allowed in Firefox. Maybe is it linked?

    Plugin Author Pedro Lamas

    (@ei99070)

    Err… on your sample here, your id’s do not match!! In the “a” element you have:
    id="les-quais"
    but in jquery:
    jQuery('#uap')

    Just set the same id in both (and don’t forget the “#” sign in jquery) and all will work ok! I just tested with Firefox 4 and works fine!!! 🙂

    martinlbb

    (@martinlbb)

    Sorry, copy/paste error.

    But now, it works. And I found my error:

    I was using window.onload, who trigger too early I think.

    Using jQuery(document).ready, It works perfectly!

    Example:

    <script type="text/JavaScript">
    jQuery(document).ready(function(){
      jQuery(document.location.hash).click();
    });
    </script>

    Thanks for your help Pedro 🙂

    Plugin Author Pedro Lamas

    (@ei99070)

    Glad all worked well!!! 🙂

    i works tq

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Plugin: jQuery Lightbox] Show lightbox on page load with Anchor’ is closed to new replies.