Closed Bug 39776 Opened 24 years ago Closed 24 years ago

No checkmark in charset menu for current document

Categories

(Core :: XUL, defect, P3)

defect

Tracking

()

VERIFIED DUPLICATE of bug 31708

People

(Reporter: cata, Assigned: cata)

References

Details

The charset menu is supposed to have a checkmark next to the character set of 
the HTML document currently being viewed by the user. The JS code I am using to 
get to that document is: 

var charset = document.commandDispatcher.focusedWindow.document.characterSet; 
dump("Update current charset: " + charset + "\n"); 

But this code returns the charset of the document contained in the focused 
window! In other words instead of getting the window containing the HTML 
document I may get the "Location" bar window. And if I move the focus manually 
on the HTML window by selecting some text, then the code will return that 
window...

So there are two possibilities here:
a) my code is wrong. In this case, please indicate the right one!
b) there is bug, please fix it.
Blocks: 31708
Target Milestone: --- → M17
your code is wrong.  when the urlbar is focused, the xul window will be focused.

just add a guard that uses window.content in the case where window == the 
focusedwindow you got from the command dispatcher
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → INVALID
The code David suggested is:
    var wnd = document.commandDispatcher.focusedWindow;
    if (window == wnd) wnd = window.content;

    var charset = wnd.document.characterSet;
	dump("Update current charset: " + charset + "\n");

And it works like a charm. Thanks David for the quick fix. You rock!
Reopened and changed summary.
No user feedback creates bad usability bug.
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
Summary: Unexpected result in getter code for the current HTML window → No checkmark in charset menu for current document
Reassigned to cata
Assignee: hyatt → cata
Status: REOPENED → NEW

*** This bug has been marked as a duplicate of 31708 ***
Status: NEW → RESOLVED
Closed: 24 years ago24 years ago
Resolution: --- → DUPLICATE
verified duplicate (or invalid)
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.