thanks for helping !
I'm trying to use the last version of BarcodeScanner (https://github.com/wildabeast/BarcodeScanner/) with ponegap on ios with Xcode 6.2. It works greats and give me the good result when scanning, but when I try to leave camera mode by clicking 'cancel', it does not works ! I have searched everywhere, I can't find a solution :/
Here my code (very basic)
html :
<body>
<input type="button" id="scanButton" value="SCAN" />
<div class="content">
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="barcodescanner.js"></script>
<script src="js/jQuery1.11.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
js
$("#scanButton").click(function(){
scanWithCordova();
});
function scanWithCordova(){
cordova.plugins.barcodeScanner.scan(
function (result) {
$('.content').html("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
},
function (error) {
alert("Scanning failed: " + error);
}
);
}
Install it from the GIT repo like this:
phonegap plugin add https://github.com/phonegap/phonegap-plugin-barcodescanner.git
It fixed it or me. I think there are bug fixes that haven't been released in the installable package yet.
Related
Ive already searched for infomation how I can do that but I cant fix this problem. I want to add a weather-widget to my webpage. It works using latitude and longitude. I want it should desplay the current weather from where the user is now.
<span id ="long"></span>
<script type='text/javascript' id="weather-link" src='https://darksky.net/widget/default/></script>
<script>const weatherLink = $("#weather-link");
weatherLink.html("<span id=\"" + response.latitude + "," +response.longitude + "\">/uk12/de.js?width=100%&height=350&title=Basel&textColor=333333&bgColor=FFFFFF&transparency=false&skyColor=undefined&fontFamily=Default&customFont=&units=uk&htColor=333333<Color=333333&displaySum=yes&displayHeader=yes</span>");
weatherLink.attr("src", weatherLink.attr("src") + response.city);</script>
The following code I use it to get users information. It works well
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$("#long").html(response.latitude + ", " + response.longitude );
$("#response").html(JSON.stringify(response, null, 4));
}, "jsonp");
</script>
I need to add to src a text that changes using that code above.
THX
I have a problem running this code with Firefox (version 32.0)
<!DOCTYPE html>
<html>
<head>
<title>Test A</title>
<script>
function showCoords(evt){
alert(
"clientX value: " + evt.clientX + "\n" +
"clientY value: " + evt.clientY + "\n"
);
}
function begin(){
parag = document.getElementById("parag");
parag.addEventListener("click", function () {showCoords(event); }, false);
}
</script>
</head>
<body onload = "begin()">
<p id="parag">To display the mouse coordinates click in this paragraph.</p>
</body>
</html>
It works in Chrome and other browsers, though when I run it with Firefox 32.0 it gives me this error:
ReferenceError: event is not defined
On the contrary, this code works in Firefox without errors:
<!DOCTYPE html>
<html>
<head>
<title>TestB</title>
<script>
function showCoords(evt){
alert(
"clientX value: " + evt.clientX + "\n" +
"clientY value: " + evt.clientY + "\n"
);
}
</script>
</head>
<body>
<p onclick="showCoords(event)">To display the mouse coordinates click in this paragraph.</p>
</body>
</html>
Can anyone tell me why the former code doesn't work while the latter does?
Again, both work in Chrome but the first is buggy in Mozilla Firefox (32.0).
Thank you in advance.
Note: don't tell me to update the browser (I must use it) nor to use jquery or similar.
Not sure if it worked in Firefox because I don't want to use Firefox.
<!DOCTYPE html>
<html>
<head>
<title>Test A</title>
<script>
function showCoords(evt){
alert(
"clientX value: " + evt.clientX + "\n" +
"clientY value: " + evt.clientY// + "\n"
);
}
function begin(){
parag = document.getElementById("parag");
parag.addEventListener("click", function(e) {showCoords(e);}, false);
}
</script>
</head>
<body onload="begin()">
<p id="parag">To display the mouse coordinates click in this paragraph.</p>
</body>
</html>
Firefox does not have the global window.event available, even the latest version(53.0), but Chrome has.
Try sending event to the begin function like this begin(event) and then send it to the showCoords function on the js side
Also in the js when accepting the event, u can try this,
event = e || windows.event so u can be sure that all browsers get covered
I was trying to copy RSS feed from Reddit site, and use below code, but received HTMLInputElement error. I am not sure if my var function is correct to get content. Please help. Thank you!
<html>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h1>Get Reddit Keyword RSS Feed</h1>
<input id="keyword" placeholder="Reddit Keyword">
<button id="submit">Get Reddit RSS Feed</button>
<script type="text/javascript">
$('#submit').click(function() {
if ($('#keyword').val() != '') {
alert('For demonstration purposes only. Please do not point your RSS reader to this server.');
var keyword = $('#keyword').val();
$('#output').html('').append('http://www.reddit.com/r/' + $('#keyword').val()) '/.rss').attr('href', 'http://www.reddit.com/r/' + $('#keyword').val()) '/.rss');
}
});
</script>
</body>
</html>
I think issue is with your code,
at line
$('#output').html('').append('http://www.reddit.com/r/' + $('#keyword').val()) '/.rss').attr('href', 'http://www.reddit.com/r/' + $('#keyword').val()) '/.rss');
There is syntax error, brackets are not getting closed at right places.
$('#output').html('')
.append('http://www.reddit.com/r/' + $('#keyword').val()+ '/.rss')
.attr('href', 'http://www.reddit.com/r/' + $('#keyword').val() + '/.rss');
I'm doing the PluralSight JavaScript Fundamentals course and he enters this code into the JavaScript window of jsbin (jsbin.com)
function write(message) {
document.getElementById('message').innerHTML += message + '<br/>';
}
var streetNumber = 49;
var streetName = "Brunswick";
write(typeof streetNumber + " " + streetNumber);
write(typeof streetName + " " + streetName);
and when he Previews it writes out the types and values. The video is a year old and now jsbin has a Render (not Preview) button. When I enter the above code and Render I get a blank screen.
I tried pasting the code into an .html file
<!DOCTYPE html>
<html>
<head>
<!--<meta charset=utf-8 />-->
<title>JS Test</title>
</head>
<body>
<p id="hello">Hello World</p>
<script>
function write(message) {
document.getElementById('message').innerHTML += message + '<br/>';
}
var streetNumber = 49;
var streetName = "Brunswick"';
write(typeof streetNumber + " " + streetNumber);
write(typeof streetName + " " + streetName);
</script>
</body>
</html>
and then opened the file in IE9, and the latest version of Chrome, Firefox, Safari and Opera (my OS is Win7 Ult). They all display Hello World and nothing else. I'm probably missing something really simple here, can someone help me out?
You don't have a message element. Change the #hello element to #message.
<p id="hello">Hello World</p>
To this
<p id="message">Hello World</p>
This is what is needed for the getElementById code to have a place to print your output. Without an element having the requested ID, nothing will turn up, and hence nothing will be printed.
You have a syntax error as well:
/* v----- This little guy here doesn't belong. */
var streetName = "Brunswick"';
Note the umatched single quote at the end of this string. Remove that and you should be good to go:
<html>
<body>
<script language="Javascript">
if(blackberry.location.GPSSupported) {
blackberry.location.setAidMode(1);
blackberry.location.refreshLocation();
blackberry.location.onLocationUpdate(window.alert("Your new
position is " + blackberry.location.latitude +
" degrees latitude and " +
blackberry.location.longitude +
" degrees longitude."));
}
</script>
</body>
</html>
I have tested on device blackberry 8800 and blackberry 9000 and i am getting always 0 for
blackberry.location.latitude and blackberry.location.longitude
Note:
javascript support is enabled
javascript location support is enabled
Have you read this thread on blackberryforums