2010-05-13 48 views
0

我在排除在IE中工作的网页但在Firefox中工作时遇到问题。 Firefox的调试器停在下面一行:Javascript问题适用于IE而不适用于Firefox

btnhelp = new button("btnhelp", framemenu.document.imghelp, "../images/gui/help_o.jpg", "../images/gui/help.jpg", "", "hand", true); 

我看到那个按钮是另一个类的一些原型的功能定义为这样:

function button(jscriptname, htmlobj, dnimg, dimimg, action, cursor, enabled, hlimg) 
{ 
    //object for managing buttons easily 
    this.img = htmlobj; 

    if(htmlobj.name) 
    this.name = htmlobj.name 
    else if(htmlobj.id) 
    this.name = htmlobj.id 
    else 
    this.name = "error"; 

    this.upimg = new Image(); 
    this.dnimg = new Image(); 
    this.dimimg = new Image(); 
    this.hlimg = new Image(); 

    this.upimg.src = this.img.src; 
    this.dnimg.src = dnimg; 
    this.dimimg.src = dimimg; 
    if(hlimg) 
    this.hlimg.src = hlimg; 
    this.action = action; 
    this.jscriptname = jscriptname; 

    if(cursor) 
    this.cursor = cursor; 
    else 
    this.cursor = "hand"; 

    if(enabled) 
    this.enable(); 
    else 
    this.disable(); 

    this.img.onclick= new Function(this.jscriptname + ".click();"); 
    this.img.onmouseover= new Function(this.jscriptname + ".mouseover();"); 
    this.img.onmouseout= new Function(this.jscriptname + ".mouseout();"); 
} 

button.prototype.enable = _enable; 
button.prototype.disable = _disable; 
button.prototype.mouseover = _mouseover; 
button.prototype.mouseout = _mouseout; 
button.prototype.click = _click; 
button.prototype.hilight = _hilight; 

function _enable() 
{ 
    this.img.src = this.upimg.src; 
    this.img.style.cursor = this.cursor; 
    this.enabled = true;  
} 

function _disable() 
{ 
    this.img.src = this.dimimg.src; 
    this.img.style.cursor = "default"; 
    this.enabled = false; 
} 

function _hilight(bool) 
{ 
    this.img.src = this.hlimg.src; 
    this.enabled = bool; 
} 

function _mouseover() 
{ 
    if(this.enabled) 
     this.img.src = this.dnimg.src; 
} 

function _mouseout() 
{ 
    if(this.enabled) 
    { 
     this.img.src = this.upimg.src; 
    } 
} 

function _click() 
{ 
    if(this.enabled) 
     eval(this.action); 

} 

当调试器不打bthhelp =新按钮线,它进入nsSessionStore.js:

handleEvent: function sss_handleEvent(aEvent) { 

一旦退出这个功能,它没有返回到JavaScript和下一行是永远不会被调用,导致我认为拨打新按钮时出现问题。有谁知道我需要做什么来解决这个问题?

+0

你会得到什么错误? – SLaks 2010-05-13 20:25:43

+0

你的事件处理程序是完全错误的。 – SLaks 2010-05-13 20:26:24

+0

完全没有错误 – 2010-05-13 20:26:34

回答

3

如果Firefox是上线停止

btnhelp = new button("btnhelp", framemenu.document.imghelp, "../images/gui/help_o.jpg", "../images/gui/help.jpg", "", "hand", true); 

唯一潜在的问题可能是因为存在button尚未确定或有一个问题framemenu.document.imghelp。所有其他的论点都是原始的,所以我不明白为什么会有任何问题。

我猜 - 这与任何人都可以提供给你没有更多信息一样多 - 问题在于framemenu是文档中元素的ID,但实际上并未定义为一个变量。 Internet Explorer会自动将具有有效id属性的所有元素注册为可从脚本访问的全局变量,而无需使用document.getElementById()。没有其他浏览器会这样做,您必须使用document.getElementById()或某些其他形式的元素选择。

相关问题