Open Android mobile app through javascript click function - javascript

I am trying to open an installed android mobile application via html page in Chrome browser through javascript or jQuery click function.
It seems an anchor tag tap is working fine and opening an installed app but it's not allowing when I am trying to open an app with javascript click function, href is same still it's not working.
Here is the code:
<!doctype html>
<html>
<head>
<script src="assets/js/jquery-3.3.1.min.js"></script>
</head>
<body>
<a id="openApp" href="intent://adjustify/#Intent;scheme=https;package=com.adjustify.android;end">click me 65</a>
</body>
<script>
$(document).ready(function(){
setTimeout(function(){
document.getElementById('openApp').click();
}, 2000);
});
</script>
</html>
Tried many things but no luck, any suggestion appreciated.

try this one $(document).ready(function(){ $('#openApp').click();});

Related

Chrome issue - Open mobile SMS app by clicking URL

I need to open the sms application of mobile with prefilled body and recipient by clicking on a URL.
so I wrote this code and it is working fine in firefox.
But it is not working in chrome.
<html>
<head>
<script type="text/javascript">
function f(){
window.location="sms://+12345?body=1234";}
</script>
</head>
<body onload="f();">
</body>
</html>
Any idea to fix?

Phonegap application that loads an external link on startup - Android

I'm creating a phonegap application that links to a website, which I want to load when the page is started up.
Here is what I've tried, a simple onload method calling a window.open function and I've tried a function that is called when the device is ready. I'm running the latest version of Phonegap, which is 3.5.0 and an Android HTC One running 4.4.2. Below is my code for deviceready. This code is within the index.html code, in the www folder within my Durandal applcation. I believe it's not working because I don't have the cordova.js file which is imported in the example code at this link http://docs.phonegap.com/en/3.5.0/cordova_events_events.md.html#Events
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.css" />
<link rel="stylesheet" href="lib/font-awesome/css/font-awesome.css" />
<link rel="stylesheet" href="lib/durandal/css/durandal.css" />
<script type="text/javascript" charset="UTF-8">
function onLoad () {
document.addEventListener("deviceready", function () {
window.open("http://google.com", "_system");
}, false);
}
</script>
</head>
<body onload="onLoad">
<div id="applicationHost"></div>
<script src="lib/require/require.js" data-main="app/main"></script>
</body>
</html>
Thank you for any help. This is my first stack overflow question. Please tell me if my question format isn't right and how I can improve it for future questions. Also, please suggest other ways that I can open a window on app start up using phonegap. Another option I've considered is developing an app with Android and Java, create a WebView, but that doesn't give me the cross platform deployment I want for Android and Windows Phone and I'd like to write this simple app using HTML,CSS, JS using Durandal, and PhoneGap.
Add this line just after durandal.css addition link.
<script type="text/javascript" src="cordova.js"></script>
Without cordova.js deviceready function won't fire. You don't need to see right now where is that cordova.js. It'll be added automatically by phonegap. Right now just add this line.

Google Chrome flickers calling jQuery.html() method

In my project I use jQuery.html() to refresh an element on the page. The content is received from the server using AJAX. In FF and IE it is working perfect, but in the Chrome I see that it flickers. I realized that it is not related to AJAX. Problem is that Chrome always gets images from the server even they are not changed. Following example demonstrating it. How to prevent Chrome from reloading images from server?
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<p id="XXX">
</p>
<script>
setInterval(function () {
$("#XXX").html('This is dynamic content from server with an image <img src="alarms.png">');
}, 1000);
</script>
</body>
</html>
You can check here on how to optimize caching the content. You could also try preloading the image first here.
Try putting window.onload = before your setInterval function. It will load the function when the webpage is loaded.

jquery's ready function not working on my laptop

I'm running this simple code on "000webhost" free server:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(document).ready(function(){
alert("something");
});
</script>
</head>
</html>
Thing is, this code works perfectly well if running on localhost.
Another weird thing, is that this code works on my mobile phone, and on my PC at home.
only when running on my laptop(running windows 8), it just get stucked on "waiting for stats.hosting24.com"
I have tried runnig it on latest FF,chrome,IE. - same result on each browser.
It feels like the page never finish loading on my laptop.
Any ideas on what can cause this issue?
Tools > Options > Enable JavaScript in any browser;
check your internet connection.. since you refer jquery from google CDN, if the connection is down, the page may have an issue loading its content.
Did you try this :
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(function(){
alert("something");
});
</script>
</head>
</html>​
Since
$(function(){
});
and
$(document).ready(function() {
});
are same.
I'm experiencing the same problem. Also on 000webhost.
I'm pretty sure its an issue with that host. They may be running their own scripts that are not finishing or something (I really havent investigated it).
Anyway this issue only seems to happen on 000webhost and only at certain times, at other times my javascript has run fine, which is what leads me to believe it is a problem at their end.

jQuery script not working when page viewed on localhost

I'm just starting to playing around on a Mac for the first time and I have created a very simple HTML page that uses jQuery to do a simple text swap when an h1 tag is clicked.
When I don't view the page through the webserver and just open it directly in Safari (file:///Applications/xampp/xamppfiles/htdocs/test/mypage.html) it works as expected. However, when I try to view through Apache (http://localhost/test/mypage.html) it doesn't work.
Here's the code:
<html>
<head>
<title>My Awesome Page</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" charset="utf-8">
function sayHello()
{ $('#foo').text('Hi there!');
}
</script>
</head>
<body>
<h1 id="foo" onclick="sayHello()">Click me!</h1>
</body>
</html>
Am I missing something on the Mac? Wouldn't be an Apache setting since its client-side code.. right?
I should probably also mention that I loaded XAMPP to run Apache and MySQL. I have tested Apache to ensure its working using a simple PHP file.
Steve
Use Firebug and access the page. One things that might be a culprit is that the web server cannot open jquery.js file because of file permission. Firebug will show if the jquery loaded in page, even you can add the jQuery code on-the-fly in the Console tab.
If you access it using Safari, use Web Inspector and see the if any error showed in Console tab.
One last thing, make a habit to avoid onclick, do this instead:
<script type="text/javascript" charset="utf-8">
function sayHello()
{
$('#foo').text('Hi there!');
}
//wait DOM loaded
jQuery(function($){
$('#foo').click(function(){
sayHello();
});
});
</script>
Also, it's better to put the js code near the page end, before </body>, so it would not block concurrent page element's loading.

Categories

Resources