你的位置:首页 > 信息动态 > 新闻中心
信息动态
联系我们

flash的检测和与object-c的交互

2022/5/18 4:57:15

 NSString *flashJsPath = [[NSBundle mainBundle] pathForResource:@"flash" ofType:@"js"];
    NSString *flashJsCode = [NSString stringWithContentsOfFile:flashJsPath encoding:NSUTF8StringEncoding error:nil];
    [WebView stringByEvaluatingJavaScriptFromString:flashJsPath];
    [WebView stringByEvaluatingJavaScriptFromString:@"checkFlash()"];


function sendShowFlashCommand(){

    var url = "+check+" + "flash";
    var iframe = document.createElement("IFRAME");
    iframe.setAttribute("src",url);
    document.documentElement.appendChild(iframe);
    iframe.parentNode.removeChild(iframe);
    iframe = null;
}

function checkFlash()
{
    var type="application/x-shockwave-flash";
    var embedEles = document.getElementsByTagName("embed");
    for(var i=0;i<embedElesLength;i++)
        {
            if(embedEles[i].getAttribute("type")==type)
                //通知有falsh;break;
                sendShowFlashCommand();
        }
}