How to enter text into popup window with JavaScript (or PowerShell)? - javascript

I am writing a PowerShell script that accesses a website in order to upload an image
When it presses a button, it throws up windows explorer to select a file. I want my script to enter a preselected url into the text field, however this windows explorer screen is not part of the actual document. This means I cannot access as I would a textbox or textarea.
I have the aim of translating this script into JavaScript (since PowerShell and JavaScript use almost identical code for accessing webpages), so a way to do this in (ideally native) JS would also be appreciated.
The webpage in question is: http://imageupper.com/cgi/uploads.pl
I am clicking on the first "Browse" button, which is document.getElementById('fileo1').click(), but I don't know how to enter data into the subsequent file explorer popup.

Related

How to give a user the option to choose a value in popup.html and send the value to content script (building a chrome extension)?

I'm building a chrome extension and I want to give the user the option to choose a value (with ) from inside the popup.html window. Then the user clicks on "save" and their chosen value gets transferred to the content script js file where I can use it. Any help on how to do that?

How to have Apps Script Web App work without disabling Site Isolation in Chrome?

I have a published Web App developed with Apps Script. This app has an input field to upload a file. It takes about 10s until the file is completely uploaded. If I click on any other existing input field on the page while the file is uploading, the page moves out of screen and becomes visible only part of it or sometimes I get a blank screen (it depends of which input field was clicked). The page comes back to normal only when the file is uploaded completely.
I have figured out that if I disable Site Isolation in Chrome (chrome://flags/#site-isolation-trial-opt-out) then page is displayed correctly. Also it is working fine with Internet Explorer.
Here are some screenshots.
Select a file and click button to upload
While the file is uploading
How the page is displayed after any of input fields was clicked
Any help would be appreciated.

Print PDF Created in iTextSharp and then Return Control to Browser

This is somewhat of a return to my 2012 question - Is it possible to fire a keypress event for an iframe that has been used to load a PDF file, I think I may have been mistaken accepting the answer there.
The current situation is this -
The document of the main page has an onkeypress event attached to it which will load a PDF into an object when the user scans a particular barcode.
The PDF is created using iTextSharp and has the open action set - writer.SetOpenAction(new PdfAction(PdfAction.PRINTDIALOG)) (writer is a PdfWriter).
So a user will scan the barcode which automatically loads a PDF file which opens it's print dialog. The user will then choose the printer and print the PDF. The problem comes when the user wants to scan the next unit they need to click somewhere within the html body (but outside of the PDF object) and then scan the barcode for the new PDF to be loaded.
I had a look at this and saw that it is possible to setup some kind of communication between the PDF plugin and the browser but is is possible to tell the plugin to surrender control to the browser/javascript
EDIT
Some extra background information -
I've tried using both objects and and iframes.
Using the debugger, if I type document.activeElement.id gives the ID of an element an appropriate element however (in the case of text inputs) any key presses do not appear.
Using the debugger I can use blur the active element bring focus to another element even change the value of an input but no user input is seen by the HTML/javascript when the user types/scans.
This is a legacy application runs in Internet Explorer compatibility mode.
Just to sum up - I want to scan a barcode which will open a PDF (already done) which opens it's print dialog automatically (already done) the user prints the PDF and then without any further human interaction with the page (i.e. the user does not need to use the mouse or keyboard after clicking the print button in the print dialog) the user should be able to scan another barcode which will open a new PDF.
Rather than render the PDF inside an iframe/object, why not take advantage of modern HTML5 and Mozilla's hard work and render it using https://github.com/mozilla/pdf.js/ - it is a fully HTML5/javascript PDF renderer and does not require any plugins.
There is a nice online demo at http://mozilla.github.io/pdf.js/web/viewer.html
Then you would be on the same page with JavaScript all the way down and could avoid having to pass focus/events etc between the two environments, so you could catch events anywhere on the page easily enough.

JavaScript to copy text

I want to create a javascript to copy text to clipboard and display an alert coupon copied and when user close it or clicks ok it should visit another website in new page.
basically i am using wordpress's siteorigin pagebuilder widget in which i can only provide the javascripct name as "script.js".
so what I want is when that script runs it takes the button id and copy its text to clipboard and then shows a error message and tells code copied and when user cancels the alert or click ok then it should open a link.
Currently, almost all browsers have prohibited access to the clipboard by javascript.
So, whatever you try here will fail due to browser restrictions. There are settings modifications which re-grant access to the clipboard, but they are not practicable in an end user scenario.
There are certain solutions around which are either based on a java plugin or a small flash app. The latter is the most stable and useful, can be found here:http://zeroclipboard.org/

Skip download dialog box in IE using javascript or jQuery

I need to open a document on click on a button.
For that I use window.open() method. All work well when a document type is JPEG, DOC, TIFF etc.
When document type is MSG file (Outlook mail) or any document that cannot be open in IE, the browser asks to download a file with Open, Save, Cancel options.
I need to skip this dialog box and directly start download and open a document in its native application (that happens when user clicks on Open button in download box, so I need to do it via javascript or jQuery).
I tried to use IFrame and its Source attribute, that also gives the same result.
Any Suggestions..?

Categories

Resources