Extension Development: Frozen Firefox scrollbar and dis-functional hot-keys
I am writing a Firefox extension which creates a Java applet in the 开发者_高级运维page.
function addApplet(aDocument,url,classfile,archive) {
if (navigator.javaEnabled()) { var anApplet,body; body = aDocument.getElementsByTagName('body')[0]; anApplet = aDocument.createElement('applet'); anApplet.setAttribute('CODEBASE',url); anApplet.setAttribute('code',classfile); anApplet.setAttribute('archive',archive); anApplet.setAttribute('name',"Applet"); anApplet.setAttribute('width',"0"); anApplet.setAttribute('height',"0"); body.appendChild(anApplet); } }
The JAR file loaded from the applet is 500KB in size. I noticed that sometimes the extension causes Firefox's vertical scrollbar to freeze and the hot-keys to stop working. The scroll-bar and hot-keys work fine if I prevent the extension to append the applet to the page.
Another weird behavior is -- on the frozen page if I click inside any text/search box or even address bar the scroller and the hotkeys begin to work again. The same thing happens if I switch tabs or minimize the browser window.
I am using Firefox 3.6.12 on WindowsXP.
Please help me if you have an idea regarding this or if I should provide more information.
(Hey guys this problem is still not solved....please help me out with this......)
Thanks
See if something similar happens if you load the applet from an html page that includes the tag and its children as static content, rather than content added to the DOM.
I imagine it's a problem of Firefox and java, not your code.
Applets can be tricky. I would suggest creating a page of pure HTML that works, first.
As far as suggestions for change go, 1st thing to change is the width/height of the applet. An applet with 0 size can cause all sorts of problems. Instead, give it a WxH of 20 (then later hide it using CSS).
Ok this has worked:
Solution: This behavior is the default since JDK 1.3. However you might need to prevent the applet from getting focus on startup, for example, if your applet is invisible and does not require focus at all. In this case, you can set to false the special parameter initial_focus in the HTML tag, as follows:
<applet code="MyApplet" width=50 height=50>
*<param name=initial_focus value="false">*</applet>
Cheers,
精彩评论