Emulate Click with jQuery on Page Enter / Direct Lightbox Opening


/ Published in: JavaScript
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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. }

URL: http://www.disas.de

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.