liveCycle force close document - javascript

I was tasked to create a function to "protect" document with a password.
I figured and the previous forms create a dialog asking for a password then validate it with the value in an hidden field on the form if they are not the same close the pdf file, I know this is not the most secure way to protect but the user is well aware of it and is fine with it "unless i can find a way to to automate the securing of the file.
My issue now is that i can't seems to be able to execute javascript code that would close the form "in liveCycle" because of security restriction implemented by adobe from what i understand.
I know that with acrobat pro i can use he command this.closeDoc(); to do this but everything i tried with live cycle (different version of app.execMenuItem("close"); &
event.target.closeDoc(true); ) has failed to work. Any idea how i could force the security to allow one of those two command or to use another command to close the document programmatically?
Thanks

Try using this -
app.setTimeOut('this.closeDoc(true);', 1);
It worked for me for one of my requirements in the button 'click' event.

Related

Is there a way sending email using "mailto" with a code that checks if the user has a gmail or outlook (or other) account?

I want users on my website to contact me via email, and I want to make that easy and super user friendly for them.
Is there a way to identify with that email they are using? Because the default setting to this is Outlook. The other option is when a user changed his browsers settings/has an extension that navigates to Gmail (for example) instead of Outlook (http://blog.hubspot.com/marketing/set-gmail-as-browser-default-email-client-ht).
But for users who don't, is there an other way to do that?
It's a Wordpress website (PHP) and I usually code with PHP and JS (jQuery).
I've run mailto links on many computers, for testing (for another project), and generally, the mailto link does open their default email program, without any plugins or anything. It may be different on Windows, but on Linux, Chrome OS, and Mac OS X, this is true. The possible reason that it is different on Windows is that all of the Microsoft products that come with windows are very tightly integrated into the system, and you can't truly change the default email program on Windows. But AFAIK the mailto link works the way you want it to on most operating systems.
This is maybe not the answer you want, but have you considered setting up a contact form on your website? like this.
This woud probably be the most easy way to let someone contact you without fiddling with external programms. You also woud have more controll about selectable topics and email-format.
Well, you can most definitely detect the provider they're using with simple regex. However, this will not work with people using, say, Google Apps. If you just want to recognise the domain used, you can always do something like:
$matches = array();
preg_match("/#(.*)/", "test#example.com", $matches);
return $matches[1];
However, this will only recognise the provider, not allow you to force another service. As already mentioned, I would suggest using a contact form instead of mailto.

Disabling pasting into window.prompt()

I have a web application used internally by users to enter data. The product owners decided they want to remove the users ability to paste data into a prompt that is used to make them dual key the data entered. I know of no way (and found nothing through my searching) to implement this behavior in a prompt. The application does not use jQuery, just straight JS.
I recommended just disabling copy functionality for the entire page, but they specifically want to disable pasting into the prompt. Is this feasible? If so, how can I go about implementing it?
Not possible I'm afraid. prompt() is an API built by the browser, and much like alert(), once the popup window is opened it blocks processing on the page itself, so you have no way of knowing what keys/clicks the user has carried out on the popup, other than the text they enter into it which you receive in the response.

Detect installed extensions in browsers?

Is it possible to detect via JS what extensions / add ons a user has installed on his browser? The use case was the a particular chrome extension, Autofill was setting some text values into hidden zip fields causing some validations to fail and I want to show a message to the user that this extension might create problems.
For Firefox: First snippet of code on: AddonManager.jsm - MDN
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAllAddons(function(aAddons) {
// Here aAddons is an array of Addon objects
});
// This code will execute before the code inside the callback
Must run this code in privelaged javascript, as in not a tab. You can try for specialPowers though I don't know how that works.
To run privelaged script from your site you will have to create a firefox addon and addEventListener's to your site, like a button to list the addons, you would attach a privelaged function to that.
With the addon you enable/disable addons, but users find that annoying because addons do some obtrsuvie stuff on install sometimes.
For Chrome extensions specifically, only certain extensions are detectable so this is not a very good method, but as far as I know, there are no longer any reliable methods to detect browser extensions.
For the extension that you want to detect, you would need its Extension Id and its Web accessible resource.
Some extensions have web accessible resources and some do not. If there is no web accessible resource, you will not be able to detect that extension.
To find the web accessible resource, you will need to look at the extensions chrome.manifestfile. It will tell you if there is web accessible content. For example, the chrome.manifest file might say:
content web-developer content/web-developer/ contentaccessible=yes
Generally, its not very effective to look for browser extensions since you have to know which extensions you want to detect ahead of time and many times they are undetectable.
Also, here's a good link that I used when I was trying to do the same thing here
NavigatorPlugins.mimeTypes
Take a peek at the MDN page
https://developer.mozilla.org/en-US/docs/Web/API/NavigatorPlugins.mimeTypes?redirectlocale=en-US&redirectslug=Web%2FAPI%2FNavigator.mimeTypes
Hope it helps
In JavaScript check to see if the zip field has been changed while it is hidden and show a warning to the user that an extension might be causing issues.
For Firefox you can do it with Mochitest/SpecialPowersAPI
https://developer.mozilla.org/en-US/docs/SpecialPowers

Creating a testing script which 'skips' file uploads

I am creating a testing script for my team. So far it works fine - it goes to the login form and attempts to login using the details you entered, if that fails it goes to a job description and attempts to apply for a job, selecting a random answer for each screening question until it gets to the actual application form. Unfortunately the application form includes a file upload control, which I don't appear to be able to skip over. Does anyone have any idea if I could actually skip over it or somehow click it? I am using FF7 and from previous posts I can see that apparently FF4 does it - but FF7 doesn't appear to make file uploads clickable through JS.... any ideas? Thanks in advance.
Regards,
Richard
Javascript can't access file upload inputs for security reasons (e.g. prevent malicious upload of user's files). For this kind of testing you should use a browser automation tool like Selenium http://seleniumhq.org/ (or in web service form https://saucelabs.com/).

how to check if js file is downloaded on client end

I have experienced a weird problem with javascript.
The problem page uses some jQuery code to collect data and it does input checking validation. If the validation is true, it posts to the server. Some of our users reported (10% or maybe a lot less), they could not submit on the website.
We talked with one of the users who had the problem, and were even more confused afterwards.
Tester's PC: XP, IE8, FireFox
The first time he used IE and the JavaScript validation did not fire, he was NOT able to submit data to server neither, because the validation was set to be false by default.
(it is supposed to have a error message showing up if the validation is false)
Afterwards he tested with F.F. (F.F. worked straight away).
Coming back to IE again, the validation script started working and the submit was again successful.
So, after all the tester don't have problem any more, and couldn't replicate neither.
I am wondering if there is any software or program may stop the js file from downloading properly?
Because the page is also hosted in a i-frame in another website, that is why i thinking some antivirus may think this is a across-domain threat and stopped the posting working.
If so how can i do a check to ensure all the required js files are downloaded before user doing a submit?
What else should i look into, since the problem happens on client end only, with no server-end validation yet.
#drachenstern: thanks for the edit
You could disable the submit button, enable it only after jQuery is fully loaded and executed.
For example:
<input type="submit" disabled />
then, in your Javascript,
$(function () {
$('input:submit').attr('disabled', false);
});
However, be advised that
User will not be able to submit
anything on a browser that doesn't
support Javascript
You should not
depend on Javascript to verify the
user content; always validate the
data again on the server-side.
It is possible that there is some delay in loading the javascript on the client sde. anti-Virus "Internet secutiry" products (may) do a lot of checks.
It is highly possible that the internet security product scans a call, and then decides "ok, this is safe" and then the javascript file is downloaded. There might be a delay in this.
How to avoid the situation?
Don't tie your form submit to javascript. Let it happen always, with or without javascript. If javascript is ready the user will have a good experience (immediate validation). If it is not yet ready, the user will still be able to do the submit, do the validation and throw error messages the "traditional" way - by refreshing the page
Make the user wait till the javascript is loaded. You can have a small "loading" icon somewhere in the page to tell the user he has to wait. The user can enter the data, but can't submit yet. In the background, keep checking whether the javascript is loaded (setTimeout and checking for a specific variable). Once it is loaded, you can use javascript validations
A combination of the two: Allow non-javascript submit till you know that javascript is loaded. Once done, use javascript validations.
I would suggest at first that you should always validate everything on the server. The only reason to validate on the client is to make the response to the user faster on bad inputs.
Additionally, to ensure that each file is downloaded and processed, you could always put a global var in each file, then check them in the document proper to see if each variable has been found. It's a crude back but it would work.
You didn't specify what version of IE the user was using, but the problem of the file not being loaded right away in IE sounds normal behavior to me, however quirky. I've run into that many times, and the only solution is a ctrl-F5 for me. I don't know what else to say there. It would be WONDERFUL if we could always have every browser respond the same, but we can't, so we go on. Also, what OS were they doing all this testing on? And What browser do you test on?
What behavior do you see in IE? If you're using IE8 or later, you'll have debug tools for sure, and you could always use FirebugLite to debug your pages in IE without using the IE tools. Then you could see what the page is doing in IE. Perhaps it's throwing a javascript parsing error? Are there any icons on the window chrome in IE that would give a tipoff?
But I think that if you're trying to fix the second paragraph, you're doing it wrong if you're relying on the javascript to process the validations. But I'm just one guy.

Categories

Resources