SelectionMenu

Select some text with the mouse or by tapping. A context menu appears.

Now try selecting the other way (e.g. right to left).

Notice how the popover menu conveniently appears where you finished the selection.

When clicking a menu item, the DevTools console will show the handler call result.

Only selections at least 5 characters long trigger the menu. Try double-clicking to select this word.

More Features

Select across images and headings to test robustness.

Starting a selection in the textarea and ending it outside is handled properly.

The menu disappears once you press the left mouse button down, before you release it, if the browser has cleared the selection.

Select text. Mouse down on the selection, then after a second, mouse up. Both the selection and menu should disappear.

Double click a word and right click on it. The menu should stay displayed. Don't move the mouse. Left click on the word again. Both the selection and the menu should disappear.

Browser support
ChromeFirefoxInternet ExplorerOperaSafari
YesFirefox supports multiple selections across table cellsYesYes?

An upcoming feature is to have the popover menu stay within the left and right bounds (red rectangle surrounding this text) as well.

For now, it moves automatically when it touches the top or bottom of the window. Test this by select text from top to bottom and ending near the bottom of the window. The menu will be displayed at the top.

Also, scroll down, then select some text near the bottom of the window, but with enough space for the menu to appear beneath it. Now, scroll up. Notice that when the menu touches the bottom, it automatically moves itself to the top of the selected text.

We'll illustrate with text from The Mysterious Island

Chapter 1

"Are we rising again?" "No. On the contrary." "Are we descending?" "Worse than that, captain! we are falling!" "For Heaven's sake heave out the ballast!" "There! the last sack is empty!" "Does the balloon rise?" "No!" "I hear a noise like the dashing of waves. The sea is below the car! It cannot be more than 500 feet from us!" "Overboard with every weight! ... everything!"

Such were the loud and startling words which resounded through the air, above the vast watery desert of the Pacific, about four o'clock in the evening of the 23rd of March, 1865.

The selection start and end could be...

Scroll the page so this box is close to the bottom.
Then select text...
while...
scrolling down.
Check that...
the menu is still...
tethered to the text.

... in different parent nodes.

Few can possibly have forgotten the terrible storm from the northeast, in the middle of the equinox of that year. The tempest raged without intermission from the 18th to the 26th of March. Its ravages were terrible in America, Europe, and Asia, covering a distance of eighteen hundred miles, and extending obliquely to the equator from the thirty-fifth north parallel to the fortieth south parallel. Towns were overthrown, forests uprooted, coasts devastated by the mountains of water which were precipitated on them, vessels cast on the shore, which the published accounts numbered by hundreds, whole districts leveled by waterspouts which destroyed everything they passed over, several thousand people crushed on land or drowned at sea; such were the traces of its fury, left by this devastating tempest. It surpassed in disasters those which so frightfully ravaged Havana and Guadalupe, one on the 25th of October, 1810, the other on the 26th of July, 1825.

But while so many catastrophes were taking place on land and at sea, a drama not less exciting was being enacted in the agitated air.

In fact, a balloon, as a ball might be carried on the summit of a waterspout, had been taken into the circling movement of a column of air and had traversed space at the rate of ninety miles an hour, turning round and round as if seized by some aerial maelstrom.

Beneath the lower point of the balloon swung a car, containing five passengers, scarcely visible in the midst of the thick vapor mingled with spray which hung over the surface of the ocean.

Whence, it may be asked, had come that plaything of the tempest? From what part of the world did it rise? It surely could not have started during the storm. But the storm had raged five days already, and the first symptoms were manifested on the 18th. It cannot be doubted that the balloon came from a great distance, for it could not have traveled less than two thousand miles in twenty-four hours.

At any rate the passengers, destitute of all marks for their guidance, could not have possessed the means of reckoning the route traversed since their departure. It was a remarkable fact that, although in the very midst of the furious tempest, they did not suffer from it. They were thrown about and whirled round and round without feeling the rotation in the slightest degree, or being sensible that they were removed from a horizontal position.

Their eyes could not pierce through the thick mist which had gathered beneath the car. Dark vapor was all around them. Such was the density of the atmosphere that they could not be certain whether it was day or night. No reflection of light, no sound from inhabited land, no roaring of the ocean could have reached them, through the obscurity, while suspended in those elevated zones. Their rapid descent alone had informed them of the dangers which they ran from the waves. However, the balloon, lightened of heavy articles, such as ammunition, arms, and provisions, had risen into the higher layers of the atmosphere, to a height of 4,500 feet. The voyagers, after having discovered that the sea extended beneath them, and thinking the dangers above less dreadful than those below, did not hesitate to throw overboard even their most useful articles, while they endeavored to lose no more of that fluid, the life of their enterprise, which sustained them above the abyss.

Lorem Ipsum list

The night passed in the midst of alarms which would have been death to less energetic souls. Again the day appeared and with it the tempest began to moderate. From the beginning of that day, the 24th of March, it showed symptoms of abating. At dawn, some of the lighter clouds had risen into the more lofty regions of the air. In a few hours the wind had changed from a hurricane to a fresh breeze, that is to say, the rate of the transit of the atmospheric layers was diminished by half. It was still what sailors call "a close-reefed topsail breeze," but the commotion in the elements had none the less considerably diminished.

Towards eleven o'clock, the lower region of the air was sensibly clearer. The atmosphere threw off that chilly dampness which is felt after the passage of a great meteor. The storm did not seem to have gone farther to the west. It appeared to have exhausted itself. Could it have passed away in electric sheets, as is sometimes the case with regard to the typhoons of the Indian Ocean?

This text is outside the SelectionMenu container. Selecting text from here won't trigger the menu. But, a selection starting or ending here will trigger the menu.