SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery: Autoload on page refresh?

    I have found this great facebook like liughtbox script on the net and it works perfect when I have a link to trigger it:

    <a href="mypage.php" rel="facebox">Popup Lightbox</a>

    Is there anyway I can make this trigger when a page is loaded or refreshed?

    I think this is the important part:
    Code JavaScript:
    jQuery(document).ready(function($) {
              $('a[rel*=facebox]').facebox({
                loadingImage : 'loading.gif',
                closeImage   : closelabel.png'
              })
            })

    Hope somebody can help me... Thanks in advance ;.)

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,716
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    After initializing facebox, you should be able to trigger the link itself by activating the click event on the link.

    Perhaps with something like this:

    Code javascript:
    jQuery(document).ready(function($) {
        $('a[rel*=facebox]')
        .facebox({
            loadingImage : 'loading.gif',
            closeImage   : 'closelabel.png'
        })
        .click();
    })
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    After initializing facebox, you should be able to trigger the link itself by activating the click event on the link.

    Perhaps with something like this:

    Code javascript:
    jQuery(document).ready(function($) {
        $('a[rel*=facebox]')
        .facebox({
            loadingImage : 'loading.gif',
            closeImage   : 'closelabel.png'
        })
        .click();
    })
    But I don't want to show the link on the page... I just want it to "popup" when the page is loaded... Shouldn't the "link" be a part of the javascript?

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,716
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by jmansa View Post
    But I don't want to show the link on the page...
    I would think that the above does that without showing the link.

    Quote Originally Posted by jmansa View Post
    I just want it to "popup" when the page is loaded...
    Do you have a test version of the page?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    Do you have a test version of the page?
    Sorry... Had to sleep ;-)

    Here is a link to the testpage with the link...
    http://www.mansa.dk/lightface.html

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,716
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    If you do it without a link, how is someone going to show it again after they've clicked and the content goes away?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    If you do it without a link, how is someone going to show it again after they've clicked and the content goes away?
    It is meant to be in a "if" clause in php:

    PHP Code:
    if(//new mail in mailbox//){
       // show the popupbox //

    Does this make sense?

  8. #8
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,716
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    The facebox documentation has a good section on controlling facebox programmatically, which should be of good help for you then.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  9. #9
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    The facebox documentation has a good section on controlling facebox programmatically, which should be of good help for you then.
    Oh sorry... Didn't see this... Thanks alot. You have been great help again ;-)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •