Posted By

disas on 01/29/11


Tagged

page jquery click load simulate Lightbox emulate Direct


Versions (?)

Emulate Click with jQuery on Page Enter / Direct Lightbox Opening


 / Published in: JavaScript
 

URL: http://www.disas.de

This snippet could be useful if you use an div based design eg. with a slider or something similar. it grabs variables from the base url splitted by "#".

So you can browse to your site like "http://www.example.com/#1#2" and use the first and second variable to emulate an click on a menu or an lightbox collection eg. for opening an lightbox directly when you enter the site.

  1. var subsite1 = document.URL.split("#")[1]
  2. var subsite2 = document.URL.split("#")[2]
  3. if(subsite1 == 1 || subsite1 == 2){
  4. $("#menu a:nth("+subsite1+")").click();
  5. if(subsite1 == 2 && subsite2 > 0){
  6. $("#portfolio a:nth("+((subsite2)-1)+")").click();
  7. }
  8. if(subsite1 == 3 && subsite2 > 0){
  9. $("#portfolio a:nth("+((subsite2)-1)+")").click();
  10. }
  11. }

Report this snippet  

You need to login to post a comment.