SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    May 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Greybox onload & centered

    Hi,

    I have greybox loading automatically when a user goes onto a webpage using

    Code JavaScript:
    AJS.AEV(window, 'load', function() {
              GB_show("Hello world", "http://google.com");
         });
    (from http://orangoo.com/labs/GreyBox/FAQ/#q4)

    this works perfectly with the only downside being that it appears at the top of the page. There is also a method to center the greybox on the page but only on click. I need a way to combine the two so that the greybox centers on page automatically.

    Any ideas anyone?

    I hope I have explained this properly.

    Many thanks in advance.

  2. #2
    SitePoint Evangelist TommiChi's Avatar
    Join Date
    Oct 2008
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Onload of the window you would have to execute the same method that gets invoked on click, that should do the trick.

  3. #3
    SitePoint Member
    Join Date
    May 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the syntax to get it to load in the center of the screen

    <a href="URL" title="CAPTION" rel="gb_page_center[WIDTH, HEIGHT]">HTML</a>

    Can't get the two combine though.

  4. #4
    SitePoint Evangelist TommiChi's Avatar
    Join Date
    Oct 2008
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This syntax tells me nothing, other than the fact that you have a anchor with a rel attribute (that is only read by search spiders).

    Clicking on the link will take you to a specified url, where your items are centered (I think, have not checked).

    Rather than scripting the centering of the page, you should style your elements in a style sheet, where you can use the text-align and/or margin properties.

  5. #5
    SitePoint Member
    Join Date
    Aug 2010
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi maximusimo this might help I know it a bit late and you may have found the answer to this I have trying to solve this myself and found this answer ...

    Before
    Code:
    AJS.AEV(window, 'load', function() {
              GB_show("Hello world", "http://google.com");
         });
    After
    Code:
    AJS.AEV(window, 'load', function() {
              GB_showCenter("Hello world", "http://google.com", callback_fn);
         });
    Or With Width and Height
    Code:
    AJS.AEV(window, 'load', function() {
              GB_showCenter("Hello world", "http://google.com", /* optional */ height, width, callback_fn);
         });

    For Fullscreen
    Code:
    AJS.AEV(window, 'load', function() {
              GB_showFullScreen("Hello world", "http://google.com", callback_fn);
         });
    For Page
    Code:
    AJS.AEV(window, 'load', function() {
              GB_showPage("Hello world", "http://google.com", callback_fn);
         });
    For Image
    Code:
    AJS.AEV(window, 'load', function() {
              GB_showImage("Hello world", "http://google.com", callback_fn);
         });
    Last edited by Simple User; Aug 1, 2010 at 11:10. Reason: Updates

  6. #6
    SitePoint Member
    Join Date
    May 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers Simple User,

    solution so, pardon the pun, simple.

    Thanks 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
  •