Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cordova-second-webview not working #16

Closed
cwkerk opened this issue Apr 20, 2016 · 12 comments
Closed

Cordova-second-webview not working #16

cwkerk opened this issue Apr 20, 2016 · 12 comments
Labels

Comments

@cwkerk
Copy link

cwkerk commented Apr 20, 2016

I try to use "cordova-second-webview" plugin to create extra page for new webview by code below:

mainApp.browseWeb = function(address){
if(navigator.connection.type != Connection.NONE){
var browseWebView = new webview();
browseWebView.Show("https://angularjs.org","_blank", function(){alert("WebView Success");}, function(){alert("WebView Failure");}, true);
this.WebViews.push(browseWebView);
alert('The web view is created');
}
else alert('Browse error : No network connection');
}

However, I don't get it work even to open a webview. May I know why and how to fix it?

@sebalagos90
Copy link
Contributor

Hi @cwkerk.
The "Show" method only accepts 4 parameters like this:
webview.Show(YOUR_URL [string], SUCCESS_FUNCTION [function], ERROR_FUNCTION [function], SHOULD_SHOW_LOADING [boolean]);

Best regards!

@cwkerk
Copy link
Author

cwkerk commented Apr 20, 2016

Thank you for reply.
However, after I change into "browseWebView.Show("https://angularjs.org",function(){alert("WebView Success");}, function(){alert("WebView Failure");}, true);", it still not working

@cwkerk
Copy link
Author

cwkerk commented Apr 20, 2016

I wonder why the following code doesn't work:

mainApp.browseWeb = function(address){
if(navigator.connection.type != Connection.NONE){
var browseWebView = new webview();
browseWebView.Show(address, function(){alert("WebView Success");}, function(){alert("WebView Failure");}, true);
alert('The web view is created');
}
else alert('Browse error : No network connection');
}

@sebalagos90
Copy link
Contributor

sebalagos90 commented Apr 20, 2016

What operating system did you try your code?
The mainApp.browseWeb is called in your code?

@cwkerk
Copy link
Author

cwkerk commented Apr 20, 2016

iphone 6s plus.
May I know is this plugin work for all ios version?

@sebalagos90
Copy link
Contributor

We use it daily and we don't have issues.
Please let me check it out

@cwkerk
Copy link
Author

cwkerk commented Apr 20, 2016

May I have our example code for this plugin?
Just for reference, maybe I may find the bug with that help.

@sebalagos90
Copy link
Contributor

I did create a new ionic project and wrote the following code:
$scope.click = function(){
document.addEventListener('deviceready', function(){
webview.Show('http://www.google.cl', function(){alert("WebView Success");}, function(){alert("WebView Failure");}, true);
}, false);
};
With or without device ready event works fine.

@cwkerk
Copy link
Author

cwkerk commented Apr 20, 2016

I see.
I wonder if this plugin only works with ionic framework?
I didn't use it since it is quite heavy to build app in my macbook.

@arturokunder
Copy link
Contributor

@cwkerk
It should work with any framework.
If you checkout the js code, you can see that there isnt references to any framework.

Maybe your problem is your are constructing a webview object, but webview class only has static methods

Look at @sebalagos90 code. It uses webview.Show() directly.
But in your code:

var browseWebView = new webview();  
browseWebView.Show(address, function(){alert("WebView Success");}, function(){alert("WebView Failure");}, true);

@cwkerk
Copy link
Author

cwkerk commented Apr 26, 2016

By the way, how can I make multiple webviews using this plugin?

@arturokunder
Copy link
Contributor

@cwkerk you can make multiple webviews on iOS but not in Android
In order to make it work on Android, you will need to change the code a little because there are some static variables as described in #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants