每个人都在问如何用js实现nsIContentPolicy shouldLoad()。但是现在我使用python来做这件事,在加载页面时阻止脚本。现在可以调用shoulLoad(),但不能像我预期的那样工作。当我返回-2时,脚本仍然可以加载。 我的代码是错的还是遗漏了什么?谢谢
我的python代码:
class ContentPolicy:
_com_interfaces_ = components.interfaces.nsIContentPolicy
_reg_clsid_ = "{648639fb-05a4-4695-a3a4-9cd9607951e6}"
_reg_contractid_ = "@ucweb.com/myfun;1"
def __init__(self):
print 'brasil!!!!!!!!!!!!!!!!!!!!!----------------------------------****************************--------------basil'
logging.getLogger('errinfo').debug('brasil!!!!!!!!---world cup!!!')
def __del__(self):
logging.getLogger('errinfo').debug('bye bye ----------testing-----rio')
pass
def shouldLoad(self,aContentType,aContentLocation,aRequestOrigin,aContext,aMimeTypeGuess,aExtra):
print 'world cup!!!!!!!!!!!!!!!!!!!!!!!!!---------------------------------------------------------------------*************basil'
print 'type=' , (aContentType)
logging.getLogger('errinfo').debug('type=%d' % (aContentType))
if 2 == aContentType or 4 == aContentType or 3 == aContentType or 7 == aContentType:
logging.getLogger('errinfo').debug('rejecting type=%d' % (aContentType))
print str(aContentLocation)
return (-2)
return 1
目前没有回答
相关问题 更多 >
编程相关推荐