Getting the current URL in InApp browser on Phonegap 3.0: A quick guide

Hey there, I am having trouble retrieving the current URL of an in-app browser when clicking the close button or at any time after loading a URL. Here's my code:

 var ref = window.open('http://google.com', '_blank', 'hidden=yes');
 ref.show();
 ref.addEventListener('exit', function(event) {

          alert(JSON.stringify(event));  // no data related to URL
 });

 ref.addEventListener('loadstop', function(){
    alert(window.location.href); // always get local address ie File:/// ....
  }); 

Can anyone please assist me with this issue? I came across this Stack Overflow question, but couldn't find a solution.

Answer №1

As per the documentation provided by PhoneGap at this link, you can retrieve the URL using the following code snippet:

ref.addEventListener('loadstop', function() { alert('stop: ' + event.url); });

Although it may not be possible to access the URL from the exit event directly, one workaround could be storing it in a global variable during the loadstop event and then accessing it during the exit event.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Maximizing the potential of .delegate in combination with .closest

$('.inputRadio').parent().click(function (e) { //implement delegate method here }); Looking for assistance on how to integrate the delegate method in the provided function. Any suggestions? ...

Steps for developing your own node package manager

Looking to create a CLI package manager application called mypkgname for your Github repository? You can easily install this package globally by registering it on npm: npm install -g mypkgname-cli mypkgname init myApp cd myApp npm install npm start Here ...

Create with API-19 using [email protected]

After installing Cordova using npm, I discovered that the latest version of cordova-android available is 4.1.1. I proceeded to create a project using "cordova create" and added a platform. However, when attempting to build the project, the build process fa ...

Create a solution that is compatible with both web browsers and Node.js

I am developing a versatile library that can be utilized in both the browser and in node environment. The project involves three json config files, with the latter two extending the tsconfig.json. tsconfig.json (contains build files) tsconfig.browser.js ...

The SimpleHTTPServer is causing Google Maps Places Autocomplete feature to malfunction

Currently, I am implementing a location search feature along with form auto-fill using the google.maps.places.Autocomplete functionality. While accessing the HTML file directly (file:///location.html), everything is functioning as expected. However, when ...

I am looking to dynamically insert a text field into an HTML form using jQuery or JavaScript when a specific button is clicked

This is my code snippet: <div class="rButtons"> <input type="radio" name="numbers" value="10" />10 <input type="radio" name="numbers" value="20" />20 <input type="radio" name="numbers" value="other" />other </div> ...

Error: Unable to return callback response from NodeJs function

I have a function that handles the process of reading a private key from the filesystem and generating a JWT token. The code successfully reads the file and creates a token, but it encounters an issue when attempting to callback to the calling function. De ...

Invoking a .js file within an UpdatePanel from the CodeBehind

I have been dedicating my time to self-teach ASP.NET and JavaScript for a project, and I've hit a roadblock that has consumed dozens of hours. After discovering a fantastic drag-and-drop JavaScript list online, I copied the provided source code and o ...

Setting values from json_decode into respective variables

I am working on building a Restful web service for an Android application using PHP and Slim framework. Currently, I have successfully parsed JSON data but I am looking to store the individual values associated with each key in separate variables. While I ...

dynamically loading jQuery scripts and content via ajax

I have a webpage that displays a file tree with links to different pages and subfolders. The folders are getting too large, so I want to use a jQuery script to hide them. However, the issue is that the tree is loaded dynamically through ajax, so the jQuery ...

What is the process for transferring information from a Ruby controller to an application JavaScript using AJAX?

When clicking a button, an AJAX call is made in my application.js file. It sends 3 data points to the events_controller#check action: //application.js $(document).on('click', "#check-button", function(){ ... $.ajax({ ...

Conceal elements and offspring in D3.js through the utilization of JavaScript or jQuery

I am currently customizing a fantastic force directed layout created by @eyaler (http://bl.ocks.org/eyaler/1058611) that offers multiple options. My goal is to conceal a specific node with its children using jQuery or D3 along with JavaScript, not directly ...

What is the best way to incorporate an environmental variable in my AngularJS controller?

My API Key is securely stored in my '.env' file to keep it hidden from Git. Here's a snippet of my .env file: API_TOKEN=secrettokengibberish When working on my Angular controller, I need to retrieve this variable for my AJAX call. This i ...

The sequential progression of every Intents (PendingIntents) within the code snippet of this app widget

Currently, I am in the process of learning how to create a home screen widget for Android. The following code is specifically designed for an app widget that can toggle the RingerMode between NORMAL and SILENT modes. While the functionality seems to be wo ...

Working with Three.js: Utilizing the SpotLight and dat.gui

I have implemented a SpotLight in my scene along with an OctahedronGeometry as a visual aid for the user. The SpotLight can be moved using transformControls by selecting it, which is working properly. However, the issue arises when I try to edit the setti ...

Lack of defined global array in JavaScript

I'm encountering an issue with this JavaScript code. The second alert in the (tracking_data) is displaying 'undefined', as if the variable had been deleted or cleared, but I cannot find any part of the code that would cause that. Any assista ...

Wait until the npm.load callback is returned before returning module.exports

I am currently facing a situation similar to the one depicted in this simplified example. main.js var settings = require('../settings.js'); console.log(settings.globalData); //undefined The settings.js file relies on an external module (npm) t ...

Recreating dropdown menus using jQuery Clone

Hey there, I'm facing a situation with a dropdown list. When I choose "cat1" option, it should display sub cat 1 options. However, if I add another category, it should only show cat1 options without the sub cat options. The issue is that both cat 1 a ...

Activate Jquery to display the submenu when clicked and conceal any other open submenus at the same time

I'm trying to create a responsive menu with menus and submenus using JQuery. However, as a newbie to JQuery, I'm struggling to hide a previous submenu when displaying another one. Here's the CodePen link Below is the HTML code: <nav cl ...

No reply received on the web browser

I have written a code that is intended to read a JSON file and display it in the browser. The code is functioning correctly as it prints the data to the console, but for some reason, the data is not displaying on the browser. app.post("/uploadfile&q ...