(this is a comment, but its a bit long)
Upvoted here because although you are asking the wrong question, what sits behind that question is an interesting problem and not well documented.
The menu entry asserts some behaviour which is sent to the backend server. The backend server then delivers different content. For security reasons, a web page can interact with browser chrome (i.e. the furniture outside the view of the website in the window). So the answer to the question you asked, is that you cannot invoke this from javascript. However your problem is not invoking a menu item but rather creating the same effect as invoking the menu item.
Providing a toggle to change the presentation layer on the website is straightforward, however the question should really be,
How does this menu option change the behaviour of the site?
How to implement/integrate a parallel mechanism for achieving the same result.