1 function correctly firing on IOS, 1 not firing
NickName:DJaMCo Ask DateTime:2017-09-05T20:33:14

1 function correctly firing on IOS, 1 not firing

I am struggling with mobile navigation using JS and JQuery to scroll.

I have extracted the following scripts from my site and added a brief summary of the HMTL elements.

On Desktop (chrome 60.0.3112.113) the Nav works ok and both scripts (scroll() and islandGo() - which utilises scroll()) correctly fire.

When using IOS to debug, only the islandGo() fires correctly - with the standalone scroll() not working.

Is it to do with the second being within a function 'wrapper'?

If so, then it seems relatively simple to solve, I'm just wondering if I am missing some fundamentals.

Thanks in advance

function scroll(cli) {
    "use strict";
    var target = '#'.concat(cli);
    console.log(target);
    $("html, body").animate({scrollTop: $(target).position().top - 90}, 500);
}

function island(d) {
    "use strict";
    document.cookie = "location=" + d + ";path=/;expires=1";
}

function islandGo(z) {
    "use strict";
    island(z);
    scroll('mainblock');
    console.log("Location = " + z);
}
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

<a id="navLink-l1" title="Island" class="location-content" onmouseup="javascript:islandGo('island')" style="position: relative; display: inline-block; cursor: pointer; z-index: 5; text-decoration: none; width: 200px; height: 200px;">
  <div id="content-l1-div" class="position: relative; margin: 0px auto; text-align: center; width: 100%; height: 100%">
    <span>
      ISLAND
    </span>
  </div>
</a>

<a id="navLink-l2" title="OTHER" class="body-content" onmouseup="javascript:scroll('other-content')" style="position: relative; display: inline-block; cursor: pointer; z-index: 5; text-decoration: none; width: 200px; height: 200px;">
  <div id="content-l1-div" class="position: relative; margin: 0px auto; text-align: center; width: 100%; height: 100%">
    <span>
      OTHER
    </span>
  </div>
</a>

<div id="page-spacer" style="position: relative; width: 100%; height: 1000px; background: transparent;"></div>

<div id="mainblock" style="position: relative; width: 100%; height: 500px; background: blue; padding: 200px;">
  CONTENT
</div>

<div id="page-spacer" style="position: relative; width: 100%; height: 1000px; background: transparent;"></div>

<div id="other-content" style="position: relative; width: 100%; height: 500px; background: blue; padding: 200px;">
  !! OTHER CONTENT
</div>

Copyright Notice:Content Author:「DJaMCo」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/46055094/1-function-correctly-firing-on-ios-1-not-firing

More about “1 function correctly firing on IOS, 1 not firing” related questions

1 function correctly firing on IOS, 1 not firing

I am struggling with mobile navigation using JS and JQuery to scroll. I have extracted the following scripts from my site and added a brief summary of the HMTL elements. On Desktop (chrome 60.0.3...

Show Detail

Javascript not firing properly on Mobile - iOS / Android

I have a full screen overlay menu that appears on mobile. All of the sections on this menu appear in the DOM on that page, I want to be able to click the link and it scroll down to the relevant ID

Show Detail

iOS 9 - keyup event not firing

Is anybody else having problems with the keyup event in iOS 9 not firing? Just a simple test bed replicates the issue for me. &lt;input id="txtInput" /&gt; Vanilla JS: document.getElementById('

Show Detail

Cordova DeviceReady firing in iOS but not Android

deviceready is firing in iOS but not in Android. I had to remove the android platform due to issues it was having during the build and re added it. I see the cordova.js file in my assets folder, so...

Show Detail

loadstart event not firing for InAppBrowser in phonegap 2.9

I am developing phonegap app where I need to open inAppBrowser (Which will display google login page). For that I have written below code $("#homePage").live("pageshow", function() { $("#btn...

Show Detail

KeyboardWillHideNotification not firing in iOS 9

In iOS 9 our app stopped firing the keyboardwillhide notification. Nothing has changed codewise, was wondering how to get this notification back if possible. // register for keyboard notification...

Show Detail

iOS Xamarin scheduled timer not firing

We have a scheduler logic in an Xamarin (not Forms) project, which existed for quite some time and once worked. With one of the iOS upgrades (could be quite some time ago), the scheduler stopped fi...

Show Detail

Touchstart event is not firing inside iframe iOS 6

I have a problem while selecting the text in IOS 6.The touchstart event is not firing inside an iframe while in iOS 6. On iOS 5 this is working fine.

Show Detail

iOS Swift Timer in not firing if the App is in the background

I am developing a Cocoapod library in which, i have to Call a function when timer fires. I am using that Cocoapod in an iOS App, Timer is not firing when App goes to background state private var ...

Show Detail

Touch/Click and input event listeners not firing iOS

I have an application that is just not firing input and touch or click listeners on iOS. I've looked at these questions (just an fyi though...I'm not using jQuery): jQuery click events not working...

Show Detail