Pop up's in the Browser Widget

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

gavin.funderburg
Posts: 7
Joined: Tue Mar 27, 2018 4:33 pm

Pop up's in the Browser Widget

Post by gavin.funderburg » Tue Mar 27, 2018 5:57 pm

Hello,

I am using the internet browser widget to load a web page. There is a link on the web page that, when clicked in a normal browser, opens another internet window and the file is automatically downloaded from a temp folder on the website. Pop up's must be enabled in the browser (Chrome) for the download window to appear. Whenever I run the code to simulate the pressing of the link in the browser widget, a loading symbol appears just like when I clicked the link in a normal Chrome window, but now no download window pops up nor is anything downloaded - just like when pop up's are disabled for a normal chrome window and the button is pressed.

I wanted to know how I could simulate a pop up window or open another browser widget with the download window displayed as well as download the file

The code I am using to simulate a button press is below


do "onclick="getMosPublishedVersionExcel('45-1523-1');" in widget "Browser"

The web address of the window that pops up with the download is a temporary address, but if I could somehow get that address within the program then I could just launch that URL and the file would download. Any insight/help would be great appreciated.

Thanks

gavin.funderburg
Posts: 7
Joined: Tue Mar 27, 2018 4:33 pm

Re: Pop up's in the Browser Widget

Post by gavin.funderburg » Tue Mar 27, 2018 7:34 pm

I believe I found a solution to the previous issue - but another has arisen.

I used browserNewUrlWindow pUrl to get the url of the new window and then set the url of the current browser to that one. This downloads the file, but now I am having trouble automatically saving the file that it downloads without having any user input.

bogs
Posts: 1761
Joined: Sat Feb 25, 2017 10:45 pm

Re: Pop up's in the Browser Widget

Post by bogs » Tue Mar 27, 2018 8:52 pm

gavin.funderburg wrote:
Tue Mar 27, 2018 7:34 pm
but now I am having trouble automatically saving the file that it downloads without having any user input.
I'm not sure most users would want a program surreptitiously downloading and saving files to their systems without their input. Any web browser at least prompts asking what you want to do with any files that request download, with out some kind of prompt, it might appear to be 'sneaky'.
Image

gavin.funderburg
Posts: 7
Joined: Tue Mar 27, 2018 4:33 pm

Re: Pop up's in the Browser Widget

Post by gavin.funderburg » Wed Mar 28, 2018 12:39 pm

You are certainly right that most users would not want that. However, I am writing a very specific program for my boss's use only in which he has outlined certain functionality that he wishes to see. Among those functionalities is for the program to download and save the file without his having to save it to a specific location and then browse his computer to upload it to the program.

The file is a schematic from our company website and in no way could be malicious or sneaky, though I understand the concern.

bogs
Posts: 1761
Joined: Sat Feb 25, 2017 10:45 pm

Re: Pop up's in the Browser Widget

Post by bogs » Wed Mar 28, 2018 3:29 pm

gavin.funderburg wrote:
Wed Mar 28, 2018 12:39 pm
Among those functionalities is for the program to download and save the file without his having to save it to a specific location and then browse his computer to upload it to the program.
If I follow the point of the program, and you want to get a file from your server and put it directly into Lc without prompting, why use a browser at all? Why not, for instance, just use 'get URL "http://www.yourServerAddress.com/yourFile" ', which will allow you to put it directly into whatever container your planning to put it.
Image

gavin.funderburg
Posts: 7
Joined: Tue Mar 27, 2018 4:33 pm

Re: Pop up's in the Browser Widget

Post by gavin.funderburg » Wed Mar 28, 2018 4:08 pm

As of right now, I don't have direct access to the static URL of the file. When I hit the download button in the browser, through clicking or code, it opens another window that has a temporary URL that redirects to the actual location of the file. Until I get access to the direct address, which I am in the process of communicating with IT to see if that is possible, I'm unsure of another way to do it.

The "get URL" command works great. I was unaware of the URL aspect of that command. It is now just a matter of creating a new temporary address every time I want to download a file until I can hard-code the static address in.

Thank you for your help thus far.

bogs
Posts: 1761
Joined: Sat Feb 25, 2017 10:45 pm

Re: Pop up's in the Browser Widget

Post by bogs » Wed Mar 28, 2018 10:36 pm

No problems. URL works both ways, get and put, so if your boss modifies the file once it is in Lc, you can write to 'put (what ever object the change was made in) into URL(any valid file path).
Image

gavin.funderburg
Posts: 7
Joined: Tue Mar 27, 2018 4:33 pm

Re: Pop up's in the Browser Widget

Post by gavin.funderburg » Thu Mar 29, 2018 3:32 pm

The issue I am now encountering is that the file I am "getting" is an Excel spreadsheet. Livecode obviously doesn't like excel directly imported, it must be a csv Excel file. I am having trouble getting the file directly from the address (with "get") and getting it into a format I can work with without manually saving the file and exporting it as a csv in Excel.

bogs
Posts: 1761
Joined: Sat Feb 25, 2017 10:45 pm

Re: Pop up's in the Browser Widget

Post by bogs » Thu Mar 29, 2018 4:06 pm

Well, there is the easy way out (3 separate links from http://www.aslugontheroad.com and rev, not an endorsement, just shows it can be done), and there is the harder way out .

Alternately, since you can issue shell commands from Lc, AND you (probably have Excel installed on the system), you could find out which (if any) Excel cli arguments allow formatting of the data, issue those from Lc, etc. (not an excel expert, someone else may chime in with more complete information).
Image

gavin.funderburg
Posts: 7
Joined: Tue Mar 27, 2018 4:33 pm

Re: Pop up's in the Browser Widget

Post by gavin.funderburg » Thu Mar 29, 2018 4:38 pm

Those resources will definitely be helpful, thank you.

I apologize for continuing to ask questions. The "get" command, near as I can tell, gets the contents of a file. So when used like "get URL pUrl" to retrieve an excel spreadsheet from the website it returns a jumbled, un-formatted Excel spreadsheet full of strange characters as well as the germane information. Is there a way to get the file and maintain its formatting and simply save it somewhere on the computer to then use the previously mentioned Excel/Livecode library to carry on from there?

Thanks for your help on previous questions.

Klaus
Posts: 10015
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Pop up's in the Browser Widget

Post by Klaus » Thu Mar 29, 2018 5:17 pm

Hi Gavin,

yep, that how Microsoft files appear in a text editor and LC, lotsa strange characters!
So don't look at IT, just save IT to a file on disk like :-)

Code: Select all

...
put specialfolderpath("documents") & "/ the excel file.xls" into tFileOnDisk

## Now either:
get url"http://your excel url goes here.xls"
put IT into url("binfile:" & tFileOnDisk)

## Or directly:
put url"http://your excel url goes here.xls" into url("binfile:" & tFileOnDisk)
...
Using BINFILE here is essential!


Best

Klaus

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5939
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Pop up's in the Browser Widget

Post by FourthWorld » Thu Mar 29, 2018 6:20 pm

Excel files are Zip archives. Change the file extension to .zip, open it up, and poke around. Once you have the lay of the land you can use the revZip external to automate extraction for reformatting and presentation.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

bogs
Posts: 1761
Joined: Sat Feb 25, 2017 10:45 pm

Re: Pop up's in the Browser Widget

Post by bogs » Thu Mar 29, 2018 6:25 pm

gavin.funderburg wrote:
Thu Mar 29, 2018 4:38 pm
I apologize for continuing to ask questions.
I wouldn't, the questions are reasonable and you can't learn without asking. How do you think my post count got over a 1000? :twisted:

Besides, it gives all of us a look into doing things we might not normally be (even thinking of) doing on our own, so helping you helps all of us.

Klaus and Richard's comments are especially on target.
FourthWorld wrote:
Thu Mar 29, 2018 6:20 pm
Once you have the last of the land...
I am pretty sure Richard meant "lay of the land...", but if he didn't, I'll apologize later :D
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5939
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Pop up's in the Browser Widget

Post by FourthWorld » Thu Mar 29, 2018 7:15 pm

You're right, I did. The only thing worse than typing on a phone is not typing at all.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

bogs
Posts: 1761
Joined: Sat Feb 25, 2017 10:45 pm

Re: Pop up's in the Browser Widget

Post by bogs » Thu Mar 29, 2018 8:40 pm

:mrgreen: :mrgreen:
Image

Post Reply

Return to “Internet”