Opening view controller from web view - html

I want to have a web view that loads a webpage. Webpage has few buttons and when you click a button from the web page it has to open a view-controller.
Is this possible?

I bet you are gonna use UKWebView and yes its possible to communicate between your webview and website through evaluateJavaScript(). In this way one can easily communicate between their website and app:
webView.evaluateJavaScript("document.getElementById('someElement').innerText") { (result, error) in
if error != nil {
print(result)
}
}

Related

How to navigate to a different .html page in Vue.js

Hi guys I am trying to click a button in my Vue.js page to a different .html page that exist in my public folder.
So I am using this way
<button #click="window.location='public/test.html'">See Results</button>
However I get an error that says
"Property or method "window" is not defined on the instance but referenced during render"
How do i navigate to a different page in Vue.js?
I would recommend using vue-router if you're doing the spa approach. It will prevent your page from refreshing when you go to a different page and it will be much faster. But if you don't want to do that you could just use an anchor tag to handle the navigation for you.
<a href="/test.html">
<button>See Results</button>
</a>
You can try to call a method #click="navigateToTestHtml" and put your code in it
methods: {
navigateToTestHtml() {
window.location='public/test.html'
}
}
However, as Vue is a Single Page Application I think it would be better to create another page and add routing for it. Vue Routing Docs
You can't write 'window' into button tag, because window is not defined.I suggest that can write into 'methods',eg:
methods: {
goToHtml() {
window.location = 'public/test.html';
}
}
But, if you use vue.js, I recommend you use vue-router. One page navigate to another page, eg:
methods: {
goToPage() {
this.$router.push('/another/page');
}
}
vue-router navigation usage

Connecting a view with HTML

I want to create a view for back button using HTML. Actually condition is that that view of backbutton should be connected to the another page when once if we operate the web page.
Hello you need to override the backbutton, then load your HTML page.
document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown() {
document.getElementById("target_div").innerHTML='<object type="text/html" data="target_page.html"></object>';
}

iOS WebView: open single hyperlink in external browser

There's a simple UIWebView in my iOS app. Hyperlinks open normally in my app itself. But there's a single hyperlink I want to open in external standard browser (Safari).
I image something like <a href="http://example.com" target="_safari">.
Is there anything like this?
I'm not able to make changes in the app itself. I have to do that on my website!
You can Use UIWebViewDelegate method for achieving that. Implement following method of the delegate
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
let urlStr = request.url?.absoluteString
if //urlStr is string you want {
//launch external browser
return false
}
return true
}
This method will be called every time you try to load a url in web view. You can compare if its URL you want to load, if it matches then launch external browser and return false.
try this way
<a onclick="window.open('https://www.google.co.in/', '_system');" href="#">Google</a>

webpage surfing with page curl animation ios

i have a html file that contains some data,since i display this in a webview the user has to scroll down to view the information,what i want to know is whether i can provide a page curl animation to view the contents of the html so that it becomes easier for the user to read the information by swiping across pages,
should i use pageviewcontroller? or are there any other libraries that let me have the page curl effect on a custom(webview)? how do i proceed? is it possible to show some amount of html information on one page and then user turns to the next page? how do i achieve that,its a single html file
If you want that sort of paging, then maybe you could try the leaves library https://github.com/brow/leaves You can use it to page through various UIWebView's
As you can see in the leaves sample you have to render the page in the renderPageAtIndex.
You can then use something like:
- (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx {
CGSize screensize = CGSizeMake(320,480);
UIGraphicsBeginImageContext(screensize);
CGContextRef context = UIGraphicsGetCurrentContext();
CGFloat scalingFactor = screensize.width/webView.frame.size.width;
CGContextScaleCTM(context, scalingFactor,scalingFactor);
[webView.layer renderInContext: ctx];
}
You do have to load the webview first.

Can I add a page tab app to a differenrt App profile page?

I wanted to know if I can add a page tab app I created to a different App profile page like I can add it to regular pages on Facebook. I can't see all my app profile pages(only regular pages are listed) when I click under a profile app page the link "Add to My Page".
Yes you can do that by visiting a link:
http://www.facebook.com/add.php?pages=1&api_key=APP_ID
This will bring you list of all pages (including application pages) you own, or you can specify directly which page should be used to add application to:
http://facebook.com/add.php?pages=1&api_key=APP_ID&page=PAGE_ID
If you want to do it using Graph SDK (in kind of background, silent mode - avoiding the user interaction), then you need to make a call like this
You need to get the manage_pages permission first, and then
if (accessToken) {
var data = {
"access_token": accessToken,
"app_id":applicationId
}
FB.api("/" + pageId + "/tabs", 'post', data, function(response) {
//success or failure, check it out
});
}
It will install the application on your application profile as a tab :)
Hope it will help.