I am trying to call a function through javascript via my NPRuntime plugin but when i pass an in开发者_Go百科teger value to a function,chrome detects that as NPVariantType_Double while firefox is taking same as NPVariantType_Int32. Can we do avoid this without modifying script to make sure that both firefox and chrome detects it as NPVariantType_Int32.
Short answer: no, not really. They will give it to you in the format that they decide to give it to you. I recommend you cast it to a int32.
If you're really worried about how it's going to come in and need the format to remain exactly the same, pass it as a string and use some form of lexical cast to convert it to the numeric format you need.
Remember that javascript is dynamically typed, so from their perspective it shouldn't matter. This is just one of those annoying things :-/ FireBreath "solves" this issue simply by not caring what the browser provides and converting it to the datatype the function says it expects.
Taxilian is right. Chrome and Opera(as far as I recall) are returning mainly NPVariantType_Double
, even if this represents the location of an element (in pixels).You can create a function that converts NPVariantType_Double
and NPVariantType_Int32
to whatever you want.
精彩评论