scriptcam will not initialize - javascript

I have setup my account on scriptcam, but can't get camera to load. I've created a test page to just get the video player up, and that won't work. I can't even get the errors to load, so I suspect that it's something to do with the scriptcam.js files not even being loaded? See below:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<title>iseYoo video test</title>
<script language="JavaScript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script language="JavaScript" src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script language="JavaScript" src="scriptcam.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#webcam").scriptcam({
onError: oopsError,
showDebug: true
});
});
function oopsError(errorId,errorMsg) {
alert(errorMsg);
}
function showCurrentVersion() {
alert($.scriptcam.version());
};
</script>
</head>
<body>
<div id="webcam"></div>
</body>
</html>

Related

Why external JS won't start?

after to make some research I took the measures to guarantee that the JS will be loaded before trying to run it but... it won't work!
This works:
<!DOCTYPE html>
<head>
<meta name="viewport" content="initial-scale=1" charset="utf-8">
</head>
<html>
<body>
<script type="text/javascript">
function initialize() {
console.log('foo')
}
window.onload = function() {
initialize();
};
</script>
</body>
</html>
But this doesn't:
<!DOCTYPE html>
<head>
<meta name="viewport" content="initial-scale=1" charset="utf-8">
</head>
<html>
<body>
<script type="text/javascript" src="test.js">
<script type="text/javascript">
window.onload = function() {
initialize();
};
</script>
</body>
</html>
test.js:
function initialize() {
console.log('foo')
}
I don't get any error. It just doesn't work. What am I doing wrong?
Thanks!
You need a closing script tag for the tag that is calling the external js file.
<script type="text/javascript" src="test.js"></script>

Basic function could not be found, if I include jQuery

This is such a basic thing, I could not figure out. Consider the following:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.js" />
<script language="JavaScript" type="text/javascript">
function Show(msg){
alert(msg);
}
</script>
</head>
<body>
<input type="button" onClick="Show('hello');" value="Show 1" />
</body>
</html>
The above sample works fine if I exclude "jquery" include. What am I missing here?
that is because self closing script tags do not work. use:
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.js"></script>
Link to reference

Why doesn't this JavaScript highlight button code work?

I am not sure why this code does not work. What I am trying to achieve is I would like to click the button and highlight some text.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>the title</title>
<script type="text/javascript"
src="/jquery/jquery-1.3.2.min.js"></script>
<script type="text/javascript"
src="/jquery/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#button").click(function(){
$(".target").effect( "highlight",
{color:"#ffff00"}, 30000 );
});
});
</script>
</head>
<body>
<button id="button">Take Hint</button>
<p><span class="target">this text needs to highlight
</span></p>
</body>
</html>

PhoneGap NFC reader on Android detecting tag but not displaying content on screen

I am trying to develop a program using PhoneGap. I would like to scan and display the tag ID from a scanned card.
When the app is built and deployed through build.phonegap.com and comes into contact with a tag the device vibrates but nothing shown on screen. Can anyone tell me what I'm doing wrong?
function ready() {
function onNfc(nfcEvent) {
var tag = nfcEvent.tag;
var tagId = nfc.bytesToHexString(tag.id);
navigator.notification.alert(tagId);
var y=document.getElementById("rand");
y.innerHTML = tagId;
}
function win() {
console.log("Listening for NFC Tags");
}
function fail(error) {
alert("Error adding NFC listener");
}
nfc.addTagDiscoveredListener(onNfc, win, fail);
}
function init() {
document.addEventListener('deviceready', ready, false);
}
HTML:
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Scan NFC</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" />
<script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
<script type="text/javascript" charset="utf-8" src="phonegap-nfc-0.4.1.js"></script>
<script type="text/javascript" charset="utf-8" src="main.js"></script>
</head>
<body>
<p>Please scan NFC tag</p>
<p id="rand"></p>
</body>
</html>
I suppose that you main.js has the function init and so on.
well the only thing that you need is add after you file main.js the call to function init
<script type="text/javascript" charset="utf-8" src="main.js"></script>
<script type="text/javascript"> init(); </script>

jquery not working inside html file

I'm trying to do a very basic jquery tutorial but I'm not able to get it to work.
I'm calling the jquery library from google and then I try to create a script inside html.
If I do the same in a .js file I wouldn't have any problem.
What am I missing here?
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js">
$(document).ready(function() {
$("a").click(function() {
alert("Hello world!");
});
});
</script>
Link
</body>
</html>
You need to split this up:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js">
$(document).ready(function() {
$("a").click(function() {
alert("Hello world!");
});
});
</script>
...into two script elements:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("a").click(function() {
alert("Hello world!");
});
});
</script>
In the snippet you gave, the code within the <script> element won't be evaluated because the browser is only evaluating the contents from the src attribute and ignoring everything else.
Move your scripts into the head element like this:
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("a").click(function () {
alert("Hello world!");
});
});
</script>
</head>
<body>
Link
</body>
</html>

Categories

Resources