# Unity - Open offline web pages in a browser window by clicking a button?

I currently have a Unity game where the user can click on buttons to open up web pages, I use the following script on the button for this...

public void OpenURL(string url)
{
Application.OpenURL(url);
}
}


The URL is then put into the box that this script produces in the inspector and works perfectly.

However what I would now like to do is open the pages OFFLINE instead, so people without an internet connection can see the information. The way I envisage doing this is to save the web pages so they can be opened up locally in a browser offline. However I am stumped as to how to tell the button to open the relevant file and open it - is there a way of doing this? Maybe save the web page file in a local folder and point the button to that file?

This would be way easier that the only alternative I can think of - to save each web page as an image and have them open up as an image popup within the game as opposed to in the browser (there are a lot, so I would rather not have to do this!)

This is for PC Standalone only.

Any help would be greatly appreciated.

• Have you tried using file:// urls? I'm not positive of the formatting of them or if you can use relative pathnames but i'm sure you can construct a url to whatever file you need on disk if the file:// is allowed. – StarWeaver Mar 16 '16 at 17:39
• Hi @StarWeaver thanks for your suggestion, I have given it a go and it does indeed open the offline files if I put the URL as the location on my computer. The only problem is getting it to work with relative addresses. Currently if I put... C:\Users\JAMES\Documents\Test Project for Maps\Links\Active_Management_Case_Study.html - it works. If I put the files in a folder called 'Links' in the build folder and use \\Links\Active_Management_Case_Study.html or file:\\Links\Active_Management_Case_Study.html nothing happens - any suggestions? It must be possible! – NIMBLE JIM Mar 16 '16 at 18:58
• UPDATE - I can get it to open the file by placing the file directly in the build folder (in the same folder as the .exe file), and simply putting the filename in the URL field. However I need to have all the files in their own folder, otherwise the .exe file is going to get lost in amongst a sea of other files. If I put them in a folder called LINKS and put 'LINKS/filename' then nothing happens. – NIMBLE JIM Mar 16 '16 at 19:53
• file://./dirname/filename maybe? Or use one of unity's functions to look up the base dir at runtime? – StarWeaver Mar 16 '16 at 20:06
• @StarWeaver - problem solved, see below. Thanks for your help. – NIMBLE JIM Mar 16 '16 at 21:07