Hi,
I would like to open automaticly a html file in my Web navigator.
I use application.executeProgram(“C:/DOCUME~1/PROPRI~1/LOCALS~1/Temp/ARC36304.htm”)
But it don’t work.
How can I open this file without specify the navigator (IE, Firefox,…)
thanks
Hi Pierre-andre,
Use the following syntax:
application.executeProgramInBackground("rundll32", "url.dll,FileProtocolHandler", filename)
So your code will look like this:
application.executeProgram('rundll32', 'url.dll,FileProtocolHandler',"C:/DOCUME~1/PROPRI~1/LOCALS~1/Temp/ARC36304.htm")
Hope this helps.
It’s perfect ![Smile :)]()
It works with html, doc, pdf… really nice !
Perhaps you know the syntax to use with Linux and Mac ?
Thanks
As posted here: http://forum.servoy.com/viewtopic.php?p=45024 You can try with:
//windows
if(utils.stringMiddle(application.getOSName(),1,7) == "Windows")
{
application.executeProgram('rundll32', 'url.dll,FileProtocolHandler',tmpfile)
}
//FreeBSD or Linux
else if(utils.stringMiddle(application.getOSName(),1,7) == "FreeBSD"||utils.stringMiddle(application.getOSName(),1,5) == "Linux")
{
application.executeProgram('mozilla', tmpfile)
}
//Mac OSX
else if(application.getOSName().match("Mac"))
{
application.executeProgram('open', tmpfile)
}
I am not sure about the linux one, I think firefox replaced mozilla for a best guess installed browser.
For a fool-proof solution you may consider creating a plugin around a library like BrowserLauncher2 (bundled with servoy) that handles the platform differences for you (we use it in developer)
Rob