faqts : Computers : Programming : Languages : JavaScript : Windows

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

19 of 44 people (43%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

How do I disable the "edit" button in the toolbar, and "view" in the menu-bar, of a browser?

Dec 11th, 2001 10:00
Jean-Bernard Valentaten, Danny Sementilli,


Well basically you can't disable those with java-script (I even dought
that you can using any other language), but you can open a new window
without a toolbar and menubar. That should solve your problem too,
although a user could still rightclick the document and select "View
Sourcecode" or if he/she uses Netscape he/she could press <ALT>-U to see
the code and he/she could still use the hotkeys for cut&paste (like
<CTRL>-C, <CTRL>-X, <CTRL>-V, <SHiFT>-<INS> etc.).
I'm not sure about that, but you might try to trap those keys too. I
won't guarantee that it works though.
Anyway, here's the code to open a new window without any bars shown:
function openNew(newUrl, title, toolFlag, menuFlag, locationFlag,
statusFlag, resizeFlag, xSize, ySize)
{
    var modeStr = "status=" + (statusFlag?"1":"0") + ", ";
    modeStr += "resizable=" + (resizeFlag?"1":"0") + ", ";
    modeStr += "location=" + (locationFlag?"1":"0") + ", ";
    modeStr += "menubar=" + (menuFlag?"1":"0") + ", ";
    modeStr += "toolbar=" + (?"1":"0") + ", ";
    modeStr += "width=" + xSize + ", height=" + ySize;
    var newWindow = window.open(newUrl, title, modeStr);
}
All the flags (toolFlag etc.) need to be set to either true or false!
HTH,
Jean