Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML Bookmark on touch screen 2

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
I have 2 bookmarks on a page, one moves the view from top to bottom, the other moves the view from bottom to top.
On my desktop dev machine, both bookmarks work as expected but on my touch screen phone, only the bottom to top link works.
This is a much simplified version of the original page but still shows the same problem.
Can anyone suggest what the problem may be?

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<title>Bookmark test</title>
</head>
<body>
<div style='font-size:50px;'>
<a href='#bottom'>Bottom</a>
<a name='#top'>
Top
</div>
<div style='height:3000px;'>
BODY 100px high
</div>
<div style='font-size:50px;'>
Bottom
<a href='#top'>Top</a>
<a name='#bottom'>
</div>
</body>
</html>

Keith
 
Hi

I would start with this :
W3C Markup Validation said:
[red]🅧[/red] Line 11, Column 6: end tag for "A" omitted, but its declaration does not permit this
[red]🅧[/red] Line 19, Column 6: end tag for "A" omitted, but its declaration does not permit this

Feherke.
feherke.ga
 
Hi

I think some joker here changed my coffee to decaffeinated... How I missed those hashes ( # ) earlier ? They must not be present in the [tt]name[/tt] attributes.


Feherke.
feherke.ga
 
I hate it when my beverage is interfered with :)
The hashes were the problem, thanks.
Still a mystery why it works with or without hashes for a mouse click.

Keith
 
The mysterious difference is not likely between the platforms (desktop/mobile) but between the different browsers running on those platforms... and their different allowances for quirky HTML.
 
Thanks Olaf although I now worry that I am becoming a nerd because I enjoyed watching that.

The main point of confusion, for me, was the fact that one worked and the other didn't. If both had failed to work, I think I would have found the solution quickly.

Keith
 
I fear noone can explain without knowing the exact conditions.

In IE both links worked,
In Firefox and Chrome only the link at the bottom lead me to top, maybe because top is a keyword anyway, even if there is no anchor with that name.
IE might remove # from names automatically, because that is what it thinks of its users...

What html becomes is important, the DOM that is built from the html is what "runs".

So you might do DOM inspection and look at the names these anchors have.

If I change both names to #ttt and #bbb the link to #ttt stops working in Firefox and Chrome, most probably as it's not the keyword top anymore.
It still works in IE, as it may do as I assume and stripe off the # of the names, so href=#name works.

"top" actually is a built in anchor you don't need to define at all, besides <a href="#"> would also mean to navigate to the same page and not specify an anchor name, so it jumps somewhere, and where? Top. Where else should it go?

I'd not worry too much why wrong code works anyway, if you know how to write right code, it's merely a matter of how much quirks a browser accepts and still tries to work. Some of the tolerance IE has leads to more undefined behaviour and quirks than it fixes quirks like unallowed chars in anchor names. I have said in another place my feeling is Mozilla is most strict about w3c standards and IEs bad reputation could actually root in trying to be too tolerant.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top