I'm wondering if there is a way to detect installed plugins on different browsers.
So far I have found that you can "detect" plugins on firefox by trying to guess if chrome://path/to/some/plugin/image.gif exists.
This code for firefox looks like this:
<img src="chrome://firebug/content/blank.gif" onload="var a=document.getElementById('FireBug'); a.innerHTML = 'You are using FireBug';" style="visibility:hidden">
<div id="FireBug">You are not using FireBug</div>
I'm interested how does the code look in IE (more important to me) and if there are other ways to accomplish this task for other browsers too?
I want to know because I'm having an idiot client who claims he doesn't have installed plugins though I'm 99,99% sure he has. The problem is that some of those plugins are breaking parts of a web site admin control panel I've wrote.
Anyway I'd be glad to hear any tips,tricks,workarounds and etc for getting the plugin list of the popular browsers (ff,ie,opera,chrome,safari) :)
This code will list all the plugins installed in the browser
<html>
<body>
<div id="example"></div>
<script type="text/javascript">
var x=navigator.plugins.length; // store the total no of plugin stored
var txt="Total plugin installed: "+x+"<br/>";
txt+="Available plugins are->"+"<br/>";
for(var i=0;i<x;i++)
{
txt+=navigator.plugins[i].name + "<br/>";
}
document.getElementById("example").innerHTML=txt;
</script>
</body>
</html>
You could try this: http://www.sliceratwork.com/detect-installed-browser-plugins-using-javascript
... but this is not going to detect browser add-ons like firebug, noscript, etc.
That script seems to detect only the following plugins:-
Java
3D Markup Language for Web
DjVu
Flash
Google Talk
Acrobat Reader
QuickTime
RealPlayer
SVG Viewer
Shockwave
Silverlight
Skype
VLC
Windows Media Player
Xara
This code will give you all the info you need:
<HTML>
<HEAD>
<TITLE>About Plug-ins</TITLE>
</HEAD>
<BODY>
<SCRIPT language="javascript">
numPlugins = navigator.plugins.length;
if (numPlugins > 0)
document.writeln("Installed plug-ins");
else
document.writeln("No plug-ins are installed.");
for (i = 0; i < numPlugins; i++) {
plugin = navigator.plugins[i];
document.write("<center><font size=+1><b>");
document.write(plugin.name);
document.writeln("</b></font></center><br>");
document.writeln("<dl>");
document.writeln("<dd>File name:");
document.write(plugin.filename);
document.write("<dd><br>");
document.write(plugin.description);
document.writeln("</dl>");
document.writeln("<p>");
document.writeln("<table border=1 >");
document.writeln("<tr>");
document.writeln("<th width=20%>Mime Type</th>");
document.writeln("<th width=50%>Description</th>");
document.writeln("<th width=20%>Suffixes</th>");
document.writeln("<th>Enabled</th>");
document.writeln("</tr>");
numTypes = plugin.length;
for (j = 0; j < numTypes; j++)
{
mimetype = plugin[j];
if (mimetype){
enabled = "No";
enabledPlugin = mimetype.enabledPlugin;
if (enabledPlugin && (enabledPlugin.name == plugin.name))
enabled = "Yes";
document.writeln("<tr align=center>");
document.writeln("<td>");
document.write(mimetype.type);
document.writeln("</td>");
document.writeln("<td>");
document.write(mimetype.description);
document.writeln("</td>");
document.writeln("<td>");
document.write(mimetype.suffixes);
document.writeln("</td>");
document.writeln("<td>");
document.writeln(enabled);
document.writeln("</td>");
document.writeln("</tr>");
}
}
document.write("</table>");
}
</SCRIPT>
</BODY>
</HTML>
Related
We are trying to acheive automation of an Intranet site. We are using HTA along with java script for this purpose. Instead of opening the site in browser, we are using an Iframe, withing the HTA itself, for it (Since the browser security settings bars us from doing anything). Eare able to login to the website,however, after every step from then we get this error message, saying "Unable to get property 'children' of undefined or null reference."
below this it also gives a URL : http://*******..*:8888/cs/domainname/cache/PT_HNAV_JS_MIN_1.js
To be more specific, it is a peoplesoft site. Can someone shed light on how to resolve this ?
Below is the HTML code :
<html>
<head>
<HTA:APPLICATION
APPLICATIONNAME="HTA"
SYSMENU="YES"
>
<meta http-equiv="x-ua-compatible" content="ie=9">
<title>HTA</title>
<script type="text/javascript">
function Start() {
var iframePage = document.getElementById('iframeid').contentDocument;
var userId = iframePage.getElementById("userid");
var passwd = iframePage.getElementById("pwd");
var form = iframePage.getElementById("login");
userId.value='##';
passwd.value='##';
form.submit();
}
</script>
</head>
<body>
<form class="form" name="form">
<input class="links" type="button" value="Project Plan" onclick="Start();" />
</form>
<iframe application="no" src="http://****.**.****:8888/psp/sitename/?cmd=login&languageCd=ENG&" width="600" height="600" id="iframeid">
</body>
</html>
I could find the first occurance of children in the relevant js file is below :
this.fakeBCReqWC = false;
var bchidden = 0;
if(eBC.childNodes.length == 0) bchidden=1;
this.bcScrollUl = ptUtil.id(pthNav.bcScrollId);
if (eBC.children[1])
var clickedURL = eBC.children[1].firstChild.href;
var nChildren = 0;
if (this.bcScrollUl)
nChildren = this.bcScrollUl.children.length;
var nIdx = 0;
if (this.fakeBCSetN) {
var isBCpath = false;
var fakechildindex = 0;
var i = 0;
while(nIdx < nChildren) {
var child = this.bcScrollUl.children[nIdx];
if(child.id && child.id.indexOf ("FAKE") != -1 && child.firstChild && child.firstChild.href == clickedURL) {
isBCpath = true; fakechildindex = nIdx; break; }
nIdx++; }
Changing x-ua-compatible to point to IE 11 resolved the issue. Earlier it pointed to IE9.
not sure why you did application="no"
you should do application="yes" to enable the iframe and parent hta window to communicate and allow your hta to work with the iframe dom.
however, that is from my experience with HTAs while working with IE6/7 and that was a long time ago
see more at msdn:
https://msdn.microsoft.com/en-us/library/ms536496(v=vs.85).aspx#Security
I have written a script to check if my browser has features. The following script is producing an error:
<!DOCTYPE HTML>
<html>
<head>
<title id="title"> code Issues </title>
</head>
<body>
//=================== testing the feature detection method by using geolocation =======================//
function geosuccess(position)
{
var cords = position.cords;
var latitude = position.latitude;
var longitude = postion.longitude;
var message = "You're at " + latitude + ", " + longitude
alert(message);
}
function geoError(errorObj)
{
alert(errorObj.message);
}
if(typeof navigator.geolocation != "undefined")
{
console.log("inside geolocation");
navigator.geolocation.getCurrentPosition(geoSuccess, geoError);
}
else
{
alert("thos page uses Geolocation and your browser doesn't support it");
}
//=================== End of testing the feature detection method by using geolocation =======================//
</script>
<h1>List Publishers Ltd.</h1>
<div class="book">
<h2>Sprout.</h2>
<p>A book by J. Daniel Bedford</p>
Read now.
</div>
</body>
</html>
If I run this I get an error that geosuccess isundefined.
I tried to debug the script and i can see it is not able to detect the function geoSuccess(position).
I hope I am not missing an object oriented concept and the error is something related to the browser maybe.
First, your code lacks an opening <script> tag but I'll assume that's just a mistake.
Second, your code defines the function as geosuccess but you pass geoSuccess to getCurrentPosition. Please check wheter the cases match in your code.
I'm learning to write a chrome extension. I want to inject a real-time time-stamp in current webpage.
I've already finished manifest.json, and html file as background. This html file will call a js file to get current time and display it.
While I do audits in chrome, it says:
The following resources are explicitly non-cacheable. Consider making them cacheable if possible:clock.html, ccc.js, cbd.js.
Here are contents of these three files:
(1) clock.html
<html>
<head>
<script src="ccc.js"></script>
</head>
<font size="7" color='red'>
<body>
<script src="cbd.js"></script>
<div id="showme"></div>
</body>
</font>
</html>
(2) ccc.js
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes()
var s=today.getSeconds();
var w=today.getMilliseconds()%1000;
h=checkTime(h);
m=checkTime(m);
s=checkTime(s);
w=checkMS(w);
document.getElementById('showme').innerHTML=h+":"+m+":"+s+":"+w;
t=setTimeout('startTime()',1);
}
function checkTime(i)
{
if (i<10)
{i="0" + i;}
return i;
}
function checkMS(i)
{
if((i>9)&&(i<100))
i="0" + i;
else if(i<10)
i="00" + i;
else
{}
return i;
}
(3)cbd.js:
window.addEventListener("load", startTime);
How to make them cacheable...?
Thanks!
Thanks guys, problem solved.
I changed my method, just inject the java script, and it finally works.
Most my work is done running on Webkit stuff and using Chrome's dev tools. But this code doesn't run in Firefox; it doesn't even throw a console error so I have no idea what's wrong. Any ideas. I'm sure its terribly easy. My code is designed to look throw a div for a specific syntax "t_" "r_" which are references to an external document; I'm trying to find all said references and replace them with hyperlink. I"m a novice JS coder so sorry for the naiveness you'll undoubtedly see in here.
(I'm using FF 22.0)
<!DOCTYPE html>
<html>
<head>
<script>
function pre_forwarder(){ //First Step
patt_1=/\[r_/g;
patt_2=/\[t_/g;
patt_S_and_R_1 = "[r_";
patt_S_and_R_2 = "[t_";
forwarder(patt_1,patt_S_and_R_1);
forwarder(patt_2,patt_S_and_R_2);
}
function forwarder(Pattern,Pre_SearchReplace){
rule_string = document.getElementById("divid");
rule_string = rule_string.innerText;
var patt1 = Pattern;
while (patt1.test(rule_string)==true)
{
begin_string = patt1.lastIndex;
fullpar_string = patt1.lastIndex + 5;
partial_string = rule_string.slice(begin_string,fullpar_string); //5 characters
//alert("partial_string-"+partial_string);
refined_string_end = partial_string.indexOf("]");
refined_str = partial_string.slice(0,refined_string_end); //raw number
full_str = Pre_SearchReplace+refined_str+"]"; //restructured
SectionNum = refined_str;
SearchReplace = full_str; //Variable to pass to parse()
//alert("S&R="+SearchReplace+" >> full_string-"+full_str);
//alert("S&R"+SearchReplace+">>SecNum-"+SectionNum+">>Pre-Search-"+Pre_SearchReplace);
Parse(SearchReplace,SectionNum,Pre_SearchReplace);
}
//var patt_end=/\[t_/g;
}
function Parse(SearchReplace,SectionNum,Pre_SearchReplace){
if (Pre_SearchReplace == patt_S_and_R_1){
ref_URL = "UEB_Ref.html#";
}else if (Pre_SearchReplace == patt_S_and_R_2){
ref_URL = "UEB_Tech.html#";
}
linkCreate = 'Link to ch-'+SectionNum+' ';
document.getElementById("divid").innerHTML = document.getElementById("divid").innerHTML.replace(SearchReplace, linkCreate);
}
function Dude(SectionNum){
alert(SectionNum);
}
</script>
</head>
<body onload="pre_forwarder();">
<button onclick="pre_forwarder();">
New Tool</button>
<div id="divid">
hello [dude] ok the end [r_12.1][r_7] [r_22]
<br>bro try this [t_15.3][t_6] [t_5.5]
</div>
<div id="hyperlink">
</div>
</body>
</html>
You've rule_string = rule_string.innerText; at line 15. FF doesn't know innerText, you need to use textContent, or a fix like:
rule_string = rule_string.innerText || rule_string.textContent;
A live demo at jsFiddle.
As a side note: Looks like your app is based on global variables. Please don't use this kind of programming technique. It'll do the job, as long as there's not much of code, but when your apps are getting larger, you'll lose control over a ton of global variables.
For starters, you can read JavaScript Guide at MDN, especially chapters 4, 8 and 9.
I'm currently working on a project for Adobe Air (1.5.3) and I need to unzip a file, copy some of its contents to another file.
Then I saw people talking about the Fzip (http://codeazur.com.br/lab/fzip) lib. The problem is that I don't know how to "import" or use this library with Javascript and Adobe Air, since Javascript doesn't have the import directive.
How can I manage to do that ?
I posted a demo of how to use FZip with Adobe Air and Javascript. I hope it hopes clear things up for you.
In short you need to pull the SWF file out of the compiled SWC (when applicable) and access the class.
The demo is pretty simple and really just a proof of concept but you should be able to extend it easily.
http://www.drybydesign.com/2010/05/12/adobe-air-fzip-without-flex/
-Ari
Ari's example is pretty good, and it got me started but he left out some pretty crucial stuff--like writing the uncompressed files back to the disk. And the zip file does not have to be hosted remotely--the thing about AIR is that it runs like a local Application...here is an example that build on the good start Ari gave us. (I am using HTML5 just to be cool and hip and modern! :)-
<!DOCTYPE HTML>
<html>
<head>
<title>Test Fzip</title>
<script type="application/x-shockwave-flash" src="scripts/fzip.swf"></script>
<script type="text/javascript" src="scripts/AIRAliases.js"></script>
<script type="text/javascript" src="scripts/AIRIntrospector.js"></script>
<script type="text/javascript" src="scripts/jquery-1.4.2.js"></script>
<script type="text/javascript">
var fzip;
if (window.runtime) {
if (!fzip)
fzip = {};
fzip.FZip = window.runtime.deng.fzip.FZip;
fzip.FZipFile = window.runtime.deng.fzip.FZipFile;
}
var file = air.File.documentsDirectory.resolvePath("test.zip");
//file.url
var zip = new fzip.FZip;
zip.addEventListener(air.Event.OPEN, onopen);
zip.addEventListener(air.Event.COMPLETE, oncomplete);
zip.load(new air.URLRequest(file.url.toString()));
function oncomplete(event) {
var count = zip.getFileCount();
alert(count);
for ( var idx = 0; idx < count; idx++)
{
var zfile = zip.getFileAt(idx);
// alert(zfile.filename);
var uzfile = air.File.applicationStorageDirectory.resolvePath(zfile.filename);
var stream = new air.FileStream();
stream.open( uzfile, air.FileMode.WRITE );
stream.writeBytes( zfile.content,0, zfile.content.length );
stream.close();
}
}
function onopen(event) {
alert("file is opened");
}
</script>
</head>
<body>
</body>
</html>