2012-10-21 4 views
2

특정 웹 페이지에 표시된 숫자의 평균을 계산하는 크롬 확장 프로그램을 만들려고합니다. 웹 페이지 그들을 표시하려면이 기능을 사용변수 값을 가로채는 방법

function MakeBody(Property, dValue, Color){ 
    document.write ("<tr>") 
    document.write ("<td width='16'> &nbsp;</td>"); 
    document.write ("<td width='10'>&nbsp;</td>"); 
    document.write ("<td><p class='NormalText'>&nbsp;&nbsp;<font color='"+Color+"'>"+Property+"</font></p></td>"); 
    document.write ("<td><p class='NormalText'>&nbsp;&nbsp;<font color='"+Color+"'><b>"+dValue+"</font></b></p></td>"); 
    document.write ("<td width='16'>&nbsp;</td>"); 
    document.write ("</tr>"); 
} 

내가 가로 채고 평균을 계산하는 데 필요한 값은 "dValue"변수에서입니다. 이것이 가능한가? 그런 다음 조작을 수행하고, 새로운 기능을 가진 MakeBody 기능을 대체 할 수있는 경우에만

답변

0

은 원래의 호출 :

// cache the original 
var __MakeBody__ = MakeBody; 

    // replace it with yours 
MakeBody = function(Property, dValue, Color) { 
    // manipulate 'dValue' here 

     // invoke the original 
    return __MakeBody__.call(this, Property, dValue, Color); 
}; 
관련 문제