[InAppBrowser Plugin] Possible to open URL in Javascript?

[InAppBrowser Plugin] Possible to open URL in Javascript?

  
Forge Component
(0)
Published on 27 Apr by OutSystems R&D
0 votes
Published on 27 Apr by OutSystems R&D

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!

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");

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()' 

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

Solution

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?

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.

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! 


AHAHAHAH

I'm a great striker :P

Henrique Batista wrote:

AHAHAHAH

I'm a great striker :P


Give this man a raise!