744
Views
8
Comments
Solved
[InAppBrowser Plugin] Possible to open URL in Javascript?
inappbrowser-plugin
Mobile icon
Forge asset by OutSystems

I have a Googlemap with markers that show an infowindow when you click on them.

The infowindow shows some text and a button, that, when clicked on, should open an url with the InAppBrowser, but this does not work.



Any way to get this to work, or another way to open an url in javascript?


Thanks in advance!

2017-07-05 22-17-18
Henrique Batista
Staff
Solution

The problem is that you don't have the scope of the declared function when you're trying to call it, a javascript node can be considered as a function(){} where you put your code inside.

I noticed that you found a solution, but alternatively, if you want to run some client side logic, you can declare a window object and then call a client action from one of his methods. See below example:


On the info window button click, just call the window object:

onclick="window.InfoWindowNavigationFunction.NavigateOnClick()"


Cheers

UserImage.jpg
Sridhar Sivaprakasam

Lars De Pauw wrote:

I have a Googlemap with markers that show an infowindow when you click on them.

The infowindow shows some text and a button, that, when clicked on, should open an url with the InAppBrowser, but this does not work.



Any way to get this to work, or another way to open an url in javascript?


Thanks in advance!

Have you tried this?

window.open("www.google.com", windowName, "height=200,width=200");

2017-05-09 08-17-10
Lars De Pauw

Sridhar Sivaprakasam wrote:

window.open("www.google.com", windowName, "height=200,width=200");

Found it yesterdaynight! Window.open() wouldn't work because the InAppBrowserPlugin is from Cordova, you have to replace 'window.open()' with 'cordova.InAppBrowser.open()' 

2017-07-05 22-17-18
Henrique Batista
Staff
Solution

The problem is that you don't have the scope of the declared function when you're trying to call it, a javascript node can be considered as a function(){} where you put your code inside.

I noticed that you found a solution, but alternatively, if you want to run some client side logic, you can declare a window object and then call a client action from one of his methods. See below example:


On the info window button click, just call the window object:

onclick="window.InfoWindowNavigationFunction.NavigateOnClick()"


Cheers

2017-05-09 08-17-10
Lars De Pauw

Hi Henrique,


Nice of you to drop by to assist me again!

Using your method:

 I've encountered a different error;


Am I placing the window.function in the wrong place?

2017-07-05 22-17-18
Henrique Batista
Staff

Uhm, that's strange because I have a running example, actually is exactly like yours (google maps infowindow on click).

The only difference between what I have and yours, is the window function declaration that is made on a previous javascript node.

Not sure if it will solve it though. Let me know if it makes any difference.

2017-05-09 08-17-10
Lars De Pauw

Henrique Batista wrote:

The only difference between what I have and yours, is the window function declaration that is made on a previous javascript node.

He shoots, he scores! That's 2 out of 2! 

Declaring the function in a JS node before the JS node where I initialize my infowindow did the trick! 


Thank you again, Henrique! 


2017-07-05 22-17-18
Henrique Batista
Staff

AHAHAHAH

I'm a great striker :P

2017-05-09 08-17-10
Lars De Pauw

Henrique Batista wrote:

AHAHAHAH

I'm a great striker :P


Give this man a raise! 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.