Discussion:
Resize Windowless plugin
t***@gmail.com
2013-05-14 12:03:44 UTC
Permalink
Hi,

Does anyone know if it is possible to resize a windowless plugin from within the plugin? By calling some browser functions .

-Christian
Benjamin Smedberg
2013-05-14 13:25:31 UTC
Permalink
Post by t***@gmail.com
Hi,
Does anyone know if it is possible to resize a windowless plugin from within the plugin? By calling some browser functions .
Plugins are like most other DOM elements in this regard. The intrinsic
size is determined using the width="" and height="" attributes on the
<object> or <embed>, but that can be overridden using CSS. You can use
normal DOM scripting (via NPRuntime) to change the size using
element.style.width, for example.

--BDS
t***@gmail.com
2013-05-14 13:35:52 UTC
Permalink
Post by Benjamin Smedberg
Post by t***@gmail.com
Hi,
Does anyone know if it is possible to resize a windowless plugin from within the plugin? By calling some browser functions .
Plugins are like most other DOM elements in this regard. The intrinsic
size is determined using the width="" and height="" attributes on the
<object> or <embed>, but that can be overridden using CSS. You can use
normal DOM scripting (via NPRuntime) to change the size using
element.style.width, for example.
--BDS
I have been searching for some samples of how to use NPRuntime however I can't find any. Are you aware of some samples?

/Christian
Kevin DeKorte
2013-05-14 13:47:02 UTC
Permalink
Post by t***@gmail.com
I have been searching for some samples of how to use NPRuntime
however I can't find any. Are you aware of some samples?
Christian,

I've done things like this to run javascript from the plugin...

void postDOMEvent(NPP mInstance, const gchar * id, const gchar * event)
{
gchar *jscript;

jscript =
g_strdup_printf("javascript:obj_gmp=document.getElementById('%s');"
"e_gmp=document.createEvent('Events');"
"e_gmp.initEvent('%s',true,true);"
"obj_gmp.dispatchEvent(e_gmp);",
id, event);
NPN_GetURL(mInstance, jscript, NULL);
g_free(jscript);
}


Kevin

- --
Get my public GnuPG key from
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x7D0BD5D1
t***@gmail.com
2013-05-14 13:58:35 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Post by t***@gmail.com
I have been searching for some samples of how to use NPRuntime
however I can't find any. Are you aware of some samples?
Christian,
I've done things like this to run javascript from the plugin...
void postDOMEvent(NPP mInstance, const gchar * id, const gchar * event)
{
gchar *jscript;
jscript =
g_strdup_printf("javascript:obj_gmp=document.getElementById('%s');"
"e_gmp=document.createEvent('Events');"
"e_gmp.initEvent('%s',true,true);"
"obj_gmp.dispatchEvent(e_gmp);",
id, event);
NPN_GetURL(mInstance, jscript, NULL);
g_free(jscript);
}
Kevin
- --
Get my public GnuPG key from
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x7D0BD5D1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iEYEARECAAYFAlGSQFYACgkQ6w2kMH0L1dG0kQCdHgn7I7XGu/4Cb8XP9KUaWmXa
U+AAnjnRJkHA146Ze7aGms1L+juZsfnB
=NVK9
-----END PGP SIGNATURE-----
I have found that you can do:

NPString str = { 0 };
str.UTF8Characters = "document.getElementById('pluginId').style.height = '30px'";
str.UTF8Length = strlen(str.UTF8Characters);

NPObject window;
mpBrowserFunctions->getvalue(npp, NPNVWindowNPObject, &window);

NPVariant result;
if(mpBrowserFunctions->evaluate(npp, &window, &str, &result))
mpBrowserFunctions->releasevariantvalue(&result);

Loading...