更好的
)方法是,假设插件总是驻留在一个名为
mainFrame
:
function findPlugin(container)
{
var plugin = null;
if (container.mainFrame != null) {
plugin = container.mainFrame.document.getElementById('slPlugin');
}
if (plugin == null && container.opener != null) {
plugin = findPlugin(container.opener.top);
}
return plugin;
}
function sendRefreshMessage(data)
{
var plugin = findPlugin(window.top);
if (plugin != null) {
try {
// Perform operation on `plugin`.
} catch (err) {
// Please avoid empty catch blocks, they're evil.
}
}
}