Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14111] iOS: Problem with webviews with anchors not scrolling to correct location in local files

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 3.1.0, Release 3.1.1, Release 3.2.0
Fix Version/sn/a
ComponentsiOS
Labelsdefect, ios, webview
ReporterUno Engborg
AssigneeUnknown
Created2013-06-03T13:36:26.000+0000
Updated2018-02-28T20:03:49.000+0000

Description

*Problem* I have a local HTML file that I would like to open in a webview in a window. The file contains HTML anchors and I would like the view to position itself to that anchor when it opens. *Note* It works on Android. The file opens in the webview positioned at the myanchorpoint anchor. *app.js*
var win = Ti.UI.createWindow({
	backgroundColor : "#FFF"
});

var webview = Titanium.UI.createWebView({
	url : 'mypage.html#myanchorpoint'
});
win.add(webview);

win.open();
*mypage.html*
<html>
	<head>
		<title>Test</title>
	</head>
	<body>
		<a href="#myanchorpoint">Go to my anchor point</a>
		<div style="height: 1600px;"></div>
		<a id="myanchorpoint">My Anchor Point</a>
	</body>
</html>

Comments

  1. Daniel Sefton 2013-06-03

    Tested and confirmed on iOS 6 simulator with Ti SDK 3.1.1 RC and 3.2 CI. However, the anchor point doesn't work on Android either (2.3.6). Can you test my code in a standard project? What Android version/device/emulator are you using? Btw, the reason I changed it from Alloy is that it's almost certainly not an Alloy issue; Alloy just wraps the underlying behavior. Thanks
  2. Uno Engborg 2013-06-03

    It works on Android 4.2.1 (tested on a Galaxy Nexus device)
  3. Daniel Sefton 2013-06-04

    I've escalated it, but I still can't get it to work on Android. On 4.0+ devices I just get "Webpage not available" when adding the hash at the end of the file. Below 4.0 devices run but don't move to the anchor point like iOS. Maybe a bug needs to be filed for that as well, but for this report we'll focus on iOS since that's what you requested.
  4. Carlos Henrique Zinato 2017-10-25

    This issue was sitting silently here for a while because the anchors were just working fine until iOS 11.0.3. Now they stop to scroll to desired location on the local HTML page. I've found this: https://medium.com/@marknote/the-odd-uiwebview-anchor-issue-with-ios-11-a57e9c164d3 which as far as I understand parses the link and scroll manually to the elementID. Besides that, I couldn't find anything else related to this issue. Do you have any idea? Thanks!

JSON Source