Make Text Appear For Windows Viewers Only - javascript

I am trying to make a website for batch files. Since batch files only work on Windows computers I want to find a code that recognizes the difference from Windows and other devices. Once I have this code I tell it to display a check mark and the download link on windows and on other platforms (iPhones, Android phones, ChromeBooks, etc.) It will say your device is not compatible with this file. I haven't found anything on the web even similar to this.

This javascript checks if the user uses windows.
if(navigator.appVersion.indexOf("Win") != -1){document.write('using windows');};

Related

Get device (mobile, laptop, tablet and so on..) name, type using native javascript

Hey guys I am trying to get the device name and type (Phone Android, Laptop Windows, Computer Mac ... and so on) using javascript and I know that it can be done using "navigator" but I want to ask you what do you think is the best approach for that. I mean every time when a browser is opening my js function should check browser name, device name and type, OS system and other info and so on.
I do not want to use any kind of external libraries.
console.log(navigator);

Open pdf documents in browser on Android 4+

I have seen several of these question from 1-2 years ago about Android pre-4.0. I want to ask this again for Android 4+.
I have a galaxy s3 running 4.3 and when I click on a pdf link it downloads the document rather than opening it in the browser.
I am building a website and it will have links to pdf documents. The desired behavior when one of my users clicks on the pdf link on their Android device is for the pdf document to just open like it would on a desktop browser.
Is there anything I can do to achieve this functionality, or does Android still not support this?
I cannot control the device that a user is using, so I'm looking for a solution that would achieve this functionality in as many cases as possible.
The stock browser does not support native viewing of PDFs. You can however redirect the link to google docs and view internally that way. To do this, launch your implicit view intent, as I suspect you are already doing, but prepend the URI with "https://docs.google.com/gview?url=" and Google will take care of the rest
Alternately, there are a few libraries that you will see linked around SO, but from what I saw while researching, most are proprietary and cost and even then they might not work 100%. Google docs is free and works as often as Google does, which given that this is their platform you have to imagine they make certain their service works close to 100% of the time.
it downloads the document rather than opening it in the browser.
"it" is a Web browser. There are many Web browsers for Android. A Web browser can do whatever it wants when the user clicks on a link to a PDF file.
The desired behavior when one of my users clicks on the pdf link on their Android device is for the pdf document to just open like it would on a desktop browser.
That is not the behavior of all desktop browsers, particularly depending upon user configuration (e.g., browser extensions). A desktop Web browser, like a mobile Web browser, is welcome to do whatever it wants when the user clicks on a link to a PDF file.
does Android still not support this?
Android is an OS. Android neither supports nor does not support this. Web browser applications will or will not support what you want.
I cannot control the device that a user is using, so I'm looking for a solution that would achieve this functionality in as many cases as possible.
You are welcome to test a variety of Android Web browsers, see if there are any that behave the way you like, and suggest to your users that you would prefer that they use those browsers. Your users, in turn, are welcome to honor or ignore your request.
Or, as Chris M points out, you are welcome to not show a PDF at all, but rather redirect the user to some URL that processes the PDF and renders it in some other way.

Launch a Windows File Explorer window from a webpage

I work in phone support for a company that released a new program that stores some data in the users appdata folder.
Our knowledge base has been updated with steps for users to turn on show hidden/system files and then steps users through opening the folders.
As a lot of our software users are not IT 'savvy', it takes a long time walking them through.
With HTML, Javascript or some kind of plug in, is it possible to make a link on a page that will launch a Windows File Explorer window navigated to %localappdata% ?
This way the user will always end up in the right place without all the steps they find difficult.
No, it isn't possible to launch an external program from within a web page.
If you could do it, it would be considered a massive security risk, and would quickly be blocked by the browser makers.
Years ago, there used to be ways to achieve this sort of thing via ActiveX controls, but that is no longer an option, largely due to the security issues it caused.
The only browser that ever supported ActiveX was IE; it doesn't work at all in any of the other browsers, and even IE defaults to block unknown ActiveX controls these days.
In short, you aren't going to be able to do this. Sorry.
I don't believe this is possible with just HTML / javascript because of permission / security
One possibility is to create a ActiveX control to launch Windows Explorer.
Building ActiveX Controls for Internet Explorer
Wikipedia - ActiveX
You could have users download and run a batch file with something like this in it:
%windir%\explorer.exe %LOCALAPPDATA%
You could even configure the batch file to copy files to a more convenient place, like the desktop.

Allow access only from mobile and tablet devices

My client has very specific request. He wants to block all "classic" computers (desktop/notebook).
So if I access the website from iPhone, Android or tablet it displays everything (the different resolutions I can hadle via responsive design). But when somebody from Mac or Windows or Linux (I know that Android is also based on gnu/linux ;) ) access the web, he gets only a message that "this web is only for mobile devices"or something like taht.
But I am not sure how to "ban" mac os, win, linux etc.
Could javascript(jQuery) library e.g. Modernizr or other do such specific condition "just mobile devices"?
What about Windows 8 :( ?
i am really thankful for any advice, because I have never had such request before?
I think you could do this in several ways.
Either you check via javascript, but then you if somebody would turn off javascript you would be screwed again because they could take a look at the website:
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
// some code..
}
or you could check it via modernizr, but I don't know exactly how to do it in modernizr and you would also have the problem of turned off javascript code,
or you could download a script that is suitable for your case via:
http://detectmobilebrowsers.com/
another thing you could do is checking the screen resolution but, then we are back at the javascript case.
According to MSDN, Windows adds Tablet PC to the browser user agent if it is a tablet.
I suggest not doing this via javascript, because as states above: if javascript is disabled, people will be able to visit your site.

Not allow any other application to open except a browser

I am presently working on website (Java EE). One of the requirements is to not let the client to open anything else other than the browser. After a lot of search I got the following results :
Change the policy of the OS.
Write some batch/c/c++ program which will intercept all the keyboard and mouse events not letting the user open anything else.
PS : It should work on windows and IE 7 or above only. The other OS and browsers need not be considered. This software is made only for intranet, so I already have control on the client machines if I have to run something.
My question is .. is there anything else I can do which will reduce the work needed on the client side or on the program which I have to write??
This is very OS specific I'd say. Windows, I believe, has APIs related to finding open windows. You could find all open windows and close them. In your application's main loop you can detect if any windows are open then close them.
Perhaps mac and ubuntu have something similar.
This might be a good place to start looking: http://msdn.microsoft.com/en-us/library/ms633497%28VS.85%29.aspx
I have no idea how to use it though.
You'll need something more powerful than javascript to communicate with your application that is monitoring the user's desktop. You may want to look at connecting JS to Silverlight then having the client download something upon opening the browser that is also similar to silverlight or .net. Then you can have them all communicate possibly.
You can set IE to be the shell process (a registry key) instead of explorer.exe, and then run IE in kiosk mode, and then disable task manager via policy (to prevent new processes).

Categories

Resources