WebHTMLViewer and local files

Is it possible to load a local file in a WebHTMLViewer

WebHTMLViewr1.URL= "file:///  --whatever -- "

Does not want to load.

Normally this is a “Https://” URL, but when Im coding/debugging it would be convent to access a local file.

No. Security and all that.

I have web sharing turned on and can get to files at http://127.0.0.1/

Brilliant

[quote=367628:@Jay Menna]Is it possible to load a local file in a WebHTMLViewer

WebHTMLViewr1.URL= "file:///  --whatever -- "

Does not want to load.

Normally this is a “Https://” URL, but when Im coding/debugging it would be convent to access a local file.[/quote]

Use a webfile.

@Michel Bujardet – I’m trying to do something similar… Obvious stupid mistake? Debugger shoes that YES the file (f) DOES exist.
WebFile (wf) does get a non-nil value with some crazy internal path in URL… but when I run my app I get a “404 : File Not Found”
Setting the In memory flag doesn’t make any difference.

Dim filename as String
Dim f as FolderItem
Dim wf as WebFile
filename = “/Users/Bob/testfile.pdf”
f=New FolderItem(filename,FolderItem.PathTypeShell)
wf = WebFile.Open(f,False)
wf.Filename = “testfile.pdf”
ShowURL(wf.URL) // Display the file

Instead of wf.url, try f.urlpath.

The reason for the 404 is that the webfile is going out of scope and it gets destroyed before the browser can request it.

Ah yes…a variable scope issue – of course. Thanks.

Hmm… the Browser “may” try to display the document. So far it always downloads the document. I was kinda hoping the browser would recognize the PDF and display it… looking at the mime type fields and stuff. Yup setting the Mime type to “application/pdf” allowed the browser to recognize it. Now…if I could just get it to open in a NEW window (or open as a new TAB — I expect pop-ups must be allowed. Sweet – the optional “True” flag on ShowURL worked (I thought that had been deprecated because peoples pop-up blockers are so prevalent that Xojo disabled the feature)

Robert, is it under Mac or Windows ?

Under Windows, only Edge and Chrome can display PDF files. Other browsers need the Adobe Acrobat Reader plugin. If the plugin is not present, the browser should offer to download the file.

About opening a new window, if a popup blocker is active (99.9% of user configurations), it should work only if you do it in a link.

Thanks Michel – I run under both Mac and Windows — but the Acrobat plugin is prevalent with my user base. I was happy the “pop-up” worked…but hadn’t considered the link option – since that’s initiated by a user click. Good advice. Thanks again.