How to calculate the height of the menubar in firefox
I try window.screen.availHeight - (document.documentElement.clientHeight + screenY) and window.screen.height - (document.documentElement.clientHeight + screenY), but failed.
I got 149px, but menubar 109px. I use screen ruller for calc this.
Modified
All Replies (10)
show me what you are doing on a random website or something, it might be a bug in Linux not Firefox. what linux distro are you running? ubuntu?
What do you think about the calculations made by this bookmarklet:
Name: toolbarsHeight
Location: javascript:void(alert(window.outerHeight-window.innerHeight));
With a maximized window, tab bar, main toolbar, compact density, I get 76. If I display the Menu Bar, I get 96. I didn't try with the Bookmarks Toolbar, but you see the idea.
tesko said
show me what you are doing on a random website or something, it might be a bug in Linux not Firefox. what linux distro are you running? ubuntu?
Ubuntu 18. I simple want get height size of menu bar. In any positions browser window.
jscher2000 said
What do you think about the calculations made by this bookmarklet: Name: toolbarsHeight Location: javascript:void(alert(window.outerHeight-window.innerHeight)); With a maximized window, tab bar, main toolbar, compact density, I get 76. If I display the Menu Bar, I get 96. I didn't try with the Bookmarks Toolbar, but you see the idea.
I need get height of menubar in any positions.
Thanks for the screenshot. It shows the height of window.outerHeight. I do not see Firefox's menu bar on your screen (File, Edit, View...). Which bar did you want to measure?
jscher2000 said
Thanks for the screenshot. It shows the height of window.outerHeight. I do not see Firefox's menu bar on your screen (File, Edit, View...). Which bar did you want to measure?
This
I think the equation I posted before should do that:
window.outerHeight-window.innerHeight
jscher2000 said
I think the equation I posted before should do that: window.outerHeight-window.innerHeight
Nope, it's not help.
Modified
Running that code in the console doesn't give the desired results. Try using the bookmarklet method as I had originally suggested. If you are not familiar with bookmarklets, they are scripts you save as bookmarks. In this case, you probably want to create it on the Bookmarks Menu. Either you can use the top menu bar (if you display it) or the Library window (Bookmarks Organizer).
- right click a spot on the bookmarks menu
- click New Bookmark...
- fill the Name and Location per my earlier post
- click the Add button
To run that from the "Library" button (), check the Recently Bookmarked list.
Alternately, you can add the Bookmarks Menu toolbar button (). To add that button, either:
(A) Use the Customize panel (Customize Firefox controls, buttons and toolbars) to drag the icon to the desired spot on the toolbar
(B) Use the method from Bookmarks in Firefox - section entitled: How do I add the Bookmarks Menu button to the toolbar?
- Click the "Library" button
- Click "Bookmarks"
- Click "Bookmarking Tools"
- Click "Add Bookmarks Menu to Toolbar"
Oh, one thing I should mention is the difference between device pixels and CSS pixels. If Firefox is not displaying at "100%" (on Windows that's 96ppi, not sure about Linux), then the number of pixels reported by JavaScript functions will be scaled.
Please see this page for an example, and test what happens when you increase or decrease zoom: