Open html files in safari

Can I save an HTML file to my iPhone and open in Safari?

Does anyone know if its possible to save an HTML file to your iphone and then open it with Safari so that you can then favourite it and have it appear on the launcher as an icon?

Did you mean copying an HTML file from a computer to the iPhone’s home screen? There is no official way of doing this. There may be a way to do it if your iPhone is jailbroken, since you have access to the file system.

Yes, that is what I meant. I have html file that does multiple cross site xmlhttprequests, which for most browsers are only allowed if the file came from a local file system and not from a server.

8 Answers 8

I do it using the ‘Notes’ app on my iphone. Quick and free download.

I emailed the file to myself, then opened it on my phone via email. Inside the email, I clicked the html file. This opened it. I then clicked the download button on the top right of my particular iphone. After that I clicked «Add to Notes».

Inside the notes app, my html file is there and also all functions work as there is also javascript involved.

Once the page is opened on your iPhone all you have to do is tap the Sharing icon, middle icon on bottom, and select ‘Add to Home Screen’

If you want to load an html file that you’ve created on you Mac to your iPhone you’ll need to do the following. From System Prefs > Sharing > Enable Web Sharing. Place the html file in your ~/Sites folder. Go the the URL listed in the Web Sharing panel from your iPhone, while on the home network, and open the html file. It will load in Mobile Safari.

If you want this to stay on your iPhone you’ll need to have the page written in html5 and have a properly setup CACHE MANIFEST. This includes the appropriate tag in the html file and have the proper manifest file. Then you can follow the first step and add it to your home screen and always have it on your iPhone.

I just put the HTML file in my DropBox and then opened it in my iOS DropBox app and then touch the ThreeDots and MakeAvailableOffline. It then opens thru the DB app while I am in airplane/offline or outside cell coverage.

HTML file I’m assuming you are talking about some pages on the web.

Читайте также:  Css меняем стиль при наведении

If so yes you can by pressing on the:

and you will have the icon on your homescreen to use it next time.

But for your information this is not the actual saving of that page it just like a favorite bookmark icon which can make you easily access to that page with a touch!.

But if you want to really save that page in an offline mode then you have to jailbreak your phone and get a tweak from Cydia which will give you an option to save it as an offline to open it next time.

And last thing if I was wrong for the above answer. And you were talking about actualy HTML code page and you want to save them and open to view the code [Source codes]

then you probably need an app from appstore [or even from cydia] or tweak from cydia to do that otherwise you can’t.

What works for me is to actually save the desired web page as a Web Archive from within Safari on the Mac, then have this file emailed to myself. On the iPhone, the only software I have that managed to open this Web Archive file successfully is GoodReader.

The only way I know of without jailbreaking is to use Dropbox.

I’ve done this using Microsoft OneDrive to generate a URL for an uploaded file. iframe embed code can also be used to display and interact with an Excel spreadsheet online.

To get the Page to your Phone there are a lot of ways to do this. You can use any Cloud Drive App you like (iCloud, OneDrive, Dropbox) it will also Work via Mail or if you have an App that Supports in App Transfer via iTunes etc.

To open/view thre Page you can use any HTML Editor App on the Phone but i have found none of them beeing able Preview the Page in Safari all of them had their own HTML Preview.

A Second Downside is that if you are somehow able to Preview the Page inside of Safari from within an App the actual File of the Page is just put to a temp Folder and when you exit the Editor App the File will get deleted.

Now if you later open the Page again over the in the Homescreen saved Icon it won’t work cause it isn’t there anymore.

If you don’t mind opening a App before opening the HTML File you can use one of the Editors or even GoodReader which can also handle HTML Files.

If you really need it to be a Icon i recommend you to write a Simple App with Just a UIWebView in it which displays your Page. If you don’t know how to do a iOS App there are many Sites out there which can help you just Google for «iOS App + UIWebView».

Читайте также:  Html webpack plugin favicon

Источник

Open Generated html file in Safari

Is there any way i can open a saved .html file in Documents directory of the application, in Safari. I have a Template.html file that i change depending on user choices and saving it to a temp.html file, how to open it in safari?

Since apps are sandboxed Safari has no access to your apps document directory. What you could do is open you HTML file in a UIWebView and display in your app.

1 Answer 1

Unfortunately you can’t open File-URLs in iOS’ Safari-App via [[UIApplication sharedApplication] openURL:] due to sandbox restrictments.

a) Upload that file to a server and then open it in the Safari-App with [[UIApplication sharedApplication] openURL:@»http://. «];

b) Embed a Safari-WebView in your app which displays the html-file, like so:

UIWebView *webView = [[UIWebView alloc] initWithFrame. ]; [self.view addSubView:webView]; NSURL *fileURL = [NSURL fileURLWithPath. ]; NSURLRequest *request = [NSURLRequest requestWithURL:fileURL]; [webView loadRequest:request]; 

self is a UIViewController here.

To add a Share-Button with proper logic, you can put the ViewController, that contains the UIWebView, inside a UINavigationController and add a UIBarButtonItem of type UIBarButtonSystemItemAction to it’s NavigationBar. If the BarButtonItem gets tapped, you show a a UIActivityViewController, like so:

- (void)viewDidLoad < [super viewDidLoad]; UIBarButtonItem *shareButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(shareButtonTapped:)]; self.navigationItem.rightBarButtonItem = shareButton; >- (void)shareButtonTapped:(id)sender

For more Infos on using UIActivityViewController, see NSHipster

Источник

How to open an HTML project on the iPad

I have an HTML project (CSS/JS/jQuery) that I’d like to test on an iPad (in Safari). From what I’ve read, iOS browsers don’t support the file:///path/to/project protocol, and even if it did, I don’t believe that you’d be able to navigate the file system to where your project is located. Please correct me on any of this information if I’m wrong, I’m an Android guy so much of this is new to me. Nonetheless, I tried to use an app called Fileapp to solve my problem. I was able to access and load my project, but it was within Fileapp’s native browser, and not Safari (unless it actually WAS Safari and it was just masked). Does anybody know of a solution to my problem (preferably free)?

@Cory I think that it’s appropriate for SO given that OP is clearly asking about testing locally and/or in a dev environment.

4 Answers 4

2016 UPDATE:

There are several services which now make this easy. If you don’t have your own web server check out one of these free services which make updating a live webpage from your PC easy:

Both of these services require using git, learn it, you won’t regret it.

Читайте также:  Плагин show damage css v34

Days of FTPing or using Dropbox to serve html to an iPad are long gone.

If you need to be able to do this while not connected to the internet check out this article on using local IP tunneling. This would essentially open up the localhost on your PC to be viewed by anyone on a wifi network, regardless of if the wifi was actually connected to the Internet.

I prefer Heroku as I am more likely to be switching between locations and PC’s than I am to be on a wifi network without an Internet connection.

OLD ANSWER 2012

Get a Dropbox account and put the project in your public folder.

Right click to get the public link and then browse to that location on your iPad.

When I get link from the iPad app it doesn’t work it just shows the raw html with a URL structure like so

When I go to the website and copy public link (only available if the file is in PUBLIC FOLDER) I get the link that actually works.

Just to make sure we’re on the same page, I’m right clicking on the project folder, and clicking «get link». it then takes me to a page with a unique URL and it displays all the files/folders in the project folder. So i type this unique URL into the Safari, and it shows the same page. I then click on the «index» page of my website, and it just shows the source code, it doesn’t render as an HTML page.

You need to make sure your getting ‘public link’ and not just ‘get link’ I believe. Is the file in yoru public folder?

Apache probably isn’t the most convenient webserver to use for this kind of ad-hoc serving of a local project. Instead, if you’re on Mac or on a Linux distribution that has Python installed (which is most of them), you can launch a webserver to serve your current working directory at the terminal with a one-liner:

python -m SimpleHTTPServer 

By default it will serve on port 8000; you can specify another port by passing it as a final argument to the command.

To connect to this server from another device, like your iPad or phone, first of all you’ll need to make sure your phone is connected to the same local network as your Mac or Linux PC. Then, on the computer, run

and look through the output for your local IP address, which will be labelled as inet addr in the output and listed under one of the connections other than «Local Loopback». On my current PC, I see inet addr:192.168.0.3 listed under the wlan0 connection.

Источник

Оцените статью