Browser back button has no effect after using easyui-layout (jquery-easyui)

96 views Asked by At

I'd like to understand why using jquery-easyui library seemingly breaks browser's back button (I'm not familiar with CSS/javascript/jQuery/HTML, so this is only an assumption).

I took an example from W3C CSS How-to's were it explains how to use javascript to redirect to an anchor within the same document and just wrapped existing <body> content in an easyui-layout, where this content is now placed in the central part of the layout.

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/default/easyui.css">
    <script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
    <style type="text/css">  
        html, body {
            height: 100%;
            overflow: hidden;
            margin: 0;
            font-family:verdana,helvetica,arial,sans-serif;
        }  
    </style>
</head>
<body>

<div class="easyui-layout" style="width:100%;height:100%;">
<div data-options="region:'center'" title="Foo">

<h2><a id="top">There is a link at the bottom of the page!</a></h2>

<p>In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.</p>
<p>"Whenever you feel like criticizing any one," he told me, "just remember that all the people in this world haven't had the advantages that you've had."</p>
<p>He didn't say any more, but we've always been unusually communicative in a reserved way, and I understood that he meant a great deal more than that. In consequence, I'm inclined to reserve all judgments, a habit that has opened up many curious natures to me and also made me the victim of not a few veteran bores. The abnormal mind is quick to detect and attach itself to this quality when it appears in a normal person, and so it came about that in college I was unjustly accused of being a politician, because I was privy to the secret griefs of wild, unknown men. Most of the confidences were unsought-frequently I have feigned sleep, preoccupation, or a hostile levity when I realized by some unmistakable sign that an intimate revelation was quivering on the horizon; for the intimate revelations of young men, or at least the terms in which they express them, are usually plagiaristic and marred by obvious suppressions. Reserving judgments is a matter of infinite hope. I am still a little afraid of missing something if I forget that, as my father snobbishly suggested, and I snobbishly repeat, a sense of the fundamental decencies is parcelled out unequally at birth.</p>
<p>And, after boasting this way of my tolerance, I come to the admission that it has a limit. Conduct may be founded on the hard rock or the wet marshes, but after a certain point I don't care what it's founded on. When I came back from the East last autumn I felt that I wanted the world to be in uniform and at a sort of moral attention forever; I wanted no more riotous excursions with privileged glimpses into the human heart. Only Gatsby, the man who gives his name to this book, was exempt from my reaction-Gatsby, who represented everything for which I have an unaffected scorn. If personality is an unbroken series of successful gestures, then there was something gorgeous about him, some heightened sensitivity to the promises of life, as if he were related to one of those intricate machines that register earthquakes ten thousand miles away. This responsiveness had nothing to do with that flabby impressionability which is dignified under the name of the "creative temperament"-it was an extraordinary gift for hope, a romantic readiness such as I have never found in any other person and which it is not likely I shall ever find again. No-Gatsby turned out all right at the end; it is what preyed on Gatsby, what foul dust floated in the wake of his dreams that temporarily closed out my interest in the abortive sorrows and short-winded elations of men.</p>
<p>And, after boasting this way of my tolerance, I come to the admission that it has a limit. Conduct may be founded on the hard rock or the wet marshes, but after a certain point I don't care what it's founded on. When I came back from the East last autumn I felt that I wanted the world to be in uniform and at a sort of moral attention forever; I wanted no more riotous excursions with privileged glimpses into the human heart. Only Gatsby, the man who gives his name to this book, was exempt from my reaction-Gatsby, who represented everything for which I have an unaffected scorn. If personality is an unbroken series of successful gestures, then there was something gorgeous about him, some heightened sensitivity to the promises of life, as if he were related to one of those intricate machines that register earthquakes ten thousand miles away. This responsiveness had nothing to do with that flabby impressionability which is dignified under the name of the "creative temperament"-it was an extraordinary gift for hope, a romantic readiness such as I have never found in any other person and which it is not likely I shall ever find again. No-Gatsby turned out all right at the end; it is what preyed on Gatsby, what foul dust floated in the wake of his dreams that temporarily closed out my interest in the abortive sorrows and short-winded elations of men.</p>

<button onclick="myFunction()">Go to top</button>

</div>
</div>

<script>
function myFunction() {
  location.href = "#top";
}
</script>

</body>
</html>

You have to resize the browser so the button needs to be scrolled to. While the original example has no issues with "going back" after clicking the "Go to top" button, the modified example doesn't work as expected anymore. I can see that the browser URL text field is set to the correct value but other than that nothing happens. Why does browser back button seemingly stop working?

I'm using version 1.5.1 of said library, if that is relevant. Tried it with up to date versions of Firefox/Chrome/Edge.

Edit: as per request in comments, jsfiddles that demonstrate my issue.

First jsfiddle, without easyui. Scroll down to the "Go to top" button, click it. Text is scrolled to top. Use ALT + LEFT to make the browser "go back". Text is scrolled to the button.

Second jsfiddle, with easyui and minor css. Scroll down to the "Go to top" button, click it. Text is scrolled to top. Use ALT + LEFT to make the browser "go back". Nothing happens.

1

There are 1 answers

7
Alexander Smirnov On

Remove "overflow: hidden;" from documents styles in the head or replace it with "overflow: auto;" or "overflow: scroll".