-2

So I have a script which opens a balloon for first time visitors. When you visit the website from an Ipad the balloon shows once and stops while on the IPhone it keeps showing whenever you access the link.

I was having a look at the code and the balloon thing is controlled by this: localStorage.setItem

Any ideas? thanks.

The important part of the code below:

  if ( !lastVisit ) lastVisit = now;

    // If it is expired we need to reissue a new balloon
    isExpired = isReturningVisitor && lastVisit <= now;

    if ( options.hookOnLoad ) w.addEventListener('load', loaded, false);
    else if ( !options.hookOnLoad && options.autostart ) loaded();
}

function loaded () {
    w.removeEventListener('load', loaded, false);

    if ( !isReturningVisitor ) w.localStorage.setItem('addToHome', Date.now());
    else if ( options.expire && isExpired ) w.localStorage.setItem('addToHome', Date.now() + options.expire * 60000);

    if ( !overrideChecks && ( !isSafari || !isExpired || isSessionActive || isStandalone || !isReturningVisitor ) ) return;

    var icons = options.touchIcon ? document.querySelectorAll('head link[rel=apple-touch-icon],head link[rel=apple-touch-icon-precomposed]') : [],
        sizes,
        touchIcon = '',
        closeButton,
        platform = nav.platform.split(' ')[0],
        language = nav.language.replace('-', '_'),
        i, l;

    balloon = document.createElement('div');
    balloon.id = 'addToHomeScreen';
    balloon.style.cssText += 'left:-9999px;-webkit-transition-property:-webkit-transform,opacity;-webkit-transition-duration:0;-webkit-transform:translate3d(0,0,0);position:' + (OSVersion < 5 ? 'absolute' : 'fixed');
bdesham
  • 15,430
  • 13
  • 79
  • 123
Rene Zammit
  • 1,121
  • 5
  • 19
  • 42
  • Please post your code! We can't diagnose your problem if we have no idea how you're implementing what you're trying to do. Also, you're talking about a website, not an iOS app, right? – bdesham Feb 20 '13 at 15:38
  • What is your actual problem? What is the desired behavior of your code, and what is it doing instead? – bdesham Feb 20 '13 at 15:49
  • I want that on the Iphone the balloon only shows ONCE. Right now the balloon for saving a link on the Iphone homepage is showing everytime a user vitis the website. This is happening only on the iphone and not Ipad – Rene Zammit Feb 20 '13 at 15:51
  • Perhaps your localStorage for your iPhone is already full? http://stackoverflow.com/q/1921048/2057171 – Albert Renshaw Feb 20 '13 at 16:37

1 Answers1

0

Issue fixed. just go to Advanced in the Safari settings and delete Website data.

Rene Zammit
  • 1,121
  • 5
  • 19
  • 42