Search Results

Search found 1 results on 1 pages for 'oliverbj'.

Page 1/1 | 1 

  • How to use this piece of code in a function

    - by oliverbj
    I have this jQuery code: var vis = (function(){ var stateKey, eventKey, keys = { hidden: "visibilitychange", webkitHidden: "webkitvisibilitychange", mozHidden: "mozvisibilitychange", msHidden: "msvisibilitychange" }; for (stateKey in keys) { if (stateKey in document) { eventKey = keys[stateKey]; break; } } return function(c) { if (c) document.addEventListener(eventKey, c); return !document[stateKey]; } })(); vis(function(){ document.title = vis() ? 'Visible' : 'Not visible'; }); What it does now is to change the document title of the page. If the page is not visible, it will be changed to that and vise verca. My question is, how can I use this function like this: if page is visible{ //do something } if page is not visible{ //do something else }

    Read the article

1