javascript - Why this code doesn't alert the browser type? -
can tell me missing in writing code?
<button onclick="getbrowsername()">you browser name?</button> <script> function getbrowsername() { //uses external interface reach out browser , grab browser useragent info. var browseragent:string = externalinterface.call("function getbrowser(){return navigator.useragent;}"); //determines brand of browser using find index. if not found indexof returns (-1). if(browseragent != null && browseragent.indexof("firefox")>= 0) { alert("firefox"); } else if(browseragent != null && browseragent.indexof("safari")>= 0) { alert("safari"); } else if(browseragent != null && browseragent.indexof("msie")>= 0) { alert("ie"); } else if(browseragent != null && browseragent.indexof("opera")>= 0) { alert("opera"); } else { alert("undefined"); } homecoming 0; } </script>
im not quite sure follow code should doing. sure correct?
var browseragent:string = externalinterface.call("function getbrowser(){return navigator.useragent;}"); i expect code this:
var browseragent = navigator.useragent; below illustration change. http://jsbin.com/lukasere/1/edit
javascript html html5 browser onclick
No comments:
Post a Comment