I am create a music library on Localhost and is it possible to use SoundManager 2play a local sound file with path, ex: D:/Music/file.mp3.
<
!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
play
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript" src="js/soundmanager2-nodebug-jsmin.js"></script>
<script type="text/javascript">
$('#play').click(function(e){
e.preventDefault()
soundManager.setup({
url: '/js/',
onready: function() {
var mySound = soundManager.createSound({
id: 'aSound',
url: 'path/to/file.mp3'
});
mySound.play();
},
ontimeout: function() {
// Hrmm, SM2 could not start. Missing SWF? Flash blocked? Show an error, etc.?
}
});
})
</script>
</body>
</html>
Related
I am trying to implement an API into my web page. However, for some reason none of the data is being displayed. I did a similar thing as I did with a previous API and it isn't working.
The following is my code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script language="JavaScript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
<script language="JavaScript" type="text/javascript">
$(function () {
var req = $.ajax({
url: "http://api.lmiforall.org.uk/api/v1/soc/search?q=computer"
});
console.log(data);
req.done(function (data) {
var wrapperDiv = $("<div />", {
"class": "wrapper"
});
var title = $("<h2 />", {
text: data[0].title
});
wrapperDiv.append(title);
$("body").append(wrapperDiv);
});
});
</script>
</body>
</html>
With the API is datatype for title, which is a job title, and I am trying to display the first title on the page. However, nothing is displayed and I get these error messages:
I honestly have no clue what is wrong with this. Any help would be much appreciated.
You log "data" outside of "done" method scope. try like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script language="JavaScript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
<script language="JavaScript" type="text/javascript">
$(function () {
var req = $.ajax({
url: "http://api.lmiforall.org.uk/api/v1/soc/search?q=computer"
});
req.done(function (data) {
console.log(data);
var wrapperDiv = $("<div />", {
"class": "wrapper"
});
var title = $("<h2 />", {
text: data[0].title
});
wrapperDiv.append(title);
$("body").append(wrapperDiv);
});
});
</script>
</body>
</html>
i develop on my local desktop machine with brackets. I currently try something with browser notifications. The strange thing is, that this code:
<!doctype html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
</head>
<body>
<button id="btn_not">Click me to get notified</button>
<script type="text/javascript">
$(document).ready(function () {
if (Notification.permission !== "granted") {
Notification.requestPermission();
}
$("#btn_not").click(function () {
createNotification();
})
})
function createNotification() {
var notification = new Notification("Hi there!");
}
</script>
</body>
</html>
doesn't work on my local machine but it does work perfectly if I upload it to my webserver, but I don't understand why?
I'm trying to scrape a web page, but getting some weird results in my browser's console (as seen below). Here's my code:
index.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Icefilms Searcher</title>
<script type="text/javascript" src="jquery-2.0.3.min.js"></script>
</head>
<body>
<script type="text/javascript" src="script.js"></script>
<div id="container" style="width:1100px;position:relative;"></div>
</body>
</html>
script.js
$(document).ready(function(){
var currNum = 168000;
var maxNum = 168005;
function generateNextUrl(){
currNum++;
return currNum-1;
}
scrapeThis(generateNextUrl());
function scrapeThis(theUrl){
$.ajax({
url:
"php.php",
data:
"icefilmsURL=" + theUrl,
success:
function(response){
var movieTitle = $(response).find("#videotitle").find("span:first").text();
$("#container").append("<a href='http://www.icefilms.info/ip.php?v="+theUrl+"' target='blank'>"+movieTitle+"</a><br>");
},
complete:
function(){
if(currNum < maxNum+1){
scrapeThis(generateNextUrl());
}
},
error:
function(xhr,err){
$("#container").append("readyState: "+xhr.readyState+"\nstatus: "+xhr.status);
$("#container").append("responseText: "+xhr.responseText);
}
});
};
});
php.php
<?php
echo file_get_contents("http://www.icefilms.info/ip.php?v=".$_GET["icefilmsURL"]);
?>
The code works fine, but this is what I see in my console:
Any ideas?
You are seeing those in the console because the page you are scraping contains references to relative paths.
That is to say rather than
<img src="http://www.icefilms.info/someimage.jpg">
The code is
<img src="someimage.jpg">
Therefore, when you grab and display their HTML on your own domain the browser is trying to load the image from your domain, localhost in this case. But you do not have the image on your server.
You can use a base href in the HTML to resolve this, or you could find and replace relative path images to include the domain.
<base href="http://www.icefilms.info/">
Below is my Geo Redirect Code that needs change,**What I would like is to add a meta redirect if possible so an eg would be:-
<html>
<head>
<title>GEO Redirect- Working Demo</title>
<!-- GEO Redirect -->
<script type="application/javascript">
function getgeoip(json){
if(json.country_code == "US"){
window.location = "http://msn.com/"
<!-- Can the above line be replaced to: <META HTTP-EQUIV='Refresh' CONTENT='0; URL=msn.com'> -->
} else {
window.location = "http://google.com/"
<!-- Can the above line be replaced to: <META HTTP-EQUIV='Refresh' CONTENT='0; URL=google.com'> -->
}
}
</script>
<script type="application/javascript" src="http://www.telize.com/geoip?callback=getgeoip"></script>
</head>
</html>
Guys any help would be highly appreciated, thanks again.
If using jquery;
$('head').append('<META HTTP-EQUIV="Refresh" CONTENT="0; URL=msn.com">');
or javascript:
var meta = document.createElement('meta');
meta.httpEquiv = "Refresh";
meta.content = "0; URL=msn.com";
document.getElementsByTagName('head')[0].appendChild(meta);
However, the rendering mode is fixed when the page is loaded, so this will most probably not work as you want it to...
If you're trying to redirect after some time, then you could do this:
<html>
<head>
<title>GEO Redirect- Working Demo</title>
<!-- GEO Redirect -->
<script type="application/javascript">
function getgeoip(json){
if(json.country_code == "US"){
// will redirect to this page, but only after 2 secs.
setTimeout(function () { window.location.href = "http://msn.com/"; }, 2000);
} else {
// will redirect to this page, but only after 2 secs.
setTimeout(function () { window.location.href = "http://google.com/"; }, 2000);
}
}
</script>
<script type="application/javascript" src="http://www.telize.com/geoip?callback=getgeoip"></script>
</head>
</html>
I am just new to XMPP, and I am making the first "HELLO" code. Please take your time look at the following code (the .zip is at the end of this topic):
<html>
<head>
<title>Hello - Chapter 3</title>
<style type="text/css">
body {
font-family: Helvetica;
}
h1 {
text-align: center;
}
.hidden {
display: none;
}
#log {
padding: 10px;
}
</style>
<script language="javascript" type="text/javascript" src="scripts/jQuery.js"></script>
<script language="javascript" type="text/javascript" src="scripts/jQueryUI.js"></script>
<script language="javascript" type="text/javascript" src="scripts/strophe.js"></script>
<script language="javascript" type="text/javascript" src="scripts/flXHR.js"></script>
<script language="javascript" type="text/javascript" src="scripts/strophe.flxhr.js"></script>
<link rel="stylesheet" href="hello.css"></link>
<script language="javascript" type="text/javascript">
var Hello = {
connection: null,
log: function(msg) {
$("#log").append("<p>" + msg + "</p>");
}
};
$(document).ready(function() {
$("#login_dialog").dialog({
autoOpen: true,
draggable: false,
modal: true,
title: "Connect to XMPP",
buttons: {
"Connect": function() {
$(document).trigger("connect", {
jid: $("#jid").val(),
password: $("#password").val()
});
$("#password").val("");
$(this).dialog("close");
}
}
});
$(document).bind("connect", function(ev, data) {
var conn = new Strophe.Connection("http://bosh.metajack.im:5280/xmpp-httpbind");
conn.connect(data.jid, data.password, function(status) {
if (status === Strophe.Status.CONNECTED) {
$(document).trigger("connected");
} else if (status === Strophe.Status.DISCONNECTED) {
$(document).trigger("disconnected");
}
});
Hello.connection = conn;
});
$(document).bind("connected", function() {
// Inform the user
Hello.log("Connection established");
});
$(document).bind("disconnected", function() {
Hello.log("Connection terminated.");
// Remove dead connection object
Hello.connection = null;
});
});
</script>
</head>
<body>
<h1>Hello</h1>
<div id="log"></div>
<!-- Login dialog -->
<div id="login_dialog" class="hidden">
<label>JID:</label><input type="text" id="jid">
<label>Pwd:</label><input type="password" id="password">
</div>
</body>
</html>
According to the document, and the code, it must either say "Connection establised" or "Connection terminated". But it doesn't. I tried to put alert("It runs to here!"); in every line of the code, and it still alert(). It doesn't alert anymore when I put it in bind("connected") and bind("disconnect"). So I guess the code can not run to there. I've never done it before, and there is rarely documents about this, so I don't know what to do now.
Question: Could you guys please take a look at it, and tell me what was wrong? I myself is still working on debugging it!
Extra information: These are what is in my web folder (I am afraid of missing javascript framework files). All js files are latest version.
index.html
scripts/
jQuery.js
jQueryUI.js
strophe.js
flensed.js
flXHR.js
flXHR.swf
flXHR.vbs
swfobject.js
updateplayer.swf
checkplayer.js
css/
Not important...
Here are my code, please take time to view it: http://xx3004.kodingen.com/XMPP
I would appreciate any view of help.
[x]
your code is alright,
the problem is in the URL provided to make the connection using Strophe.
var conn = new Strophe.Connection("http://bosh.metajack.im:5280/xmpp-httpbind");
Try to find the location of the server, otherwise install an xmpp server(vysper), locally on your machine, and change the URL as http://localhost:8080/bosh/
Also try to comment the flxhr inclusion.
If you are running Openfire on your localhost make sure
bosh_service_url = 'http://127.0.0.1:7070/http-bind/'
ie
var conn = new Strophe.Connection("http://127.0.0.1:7070/http-bind/");
And if you are running ejabberd on your localhost make sure
bosh_service_url = "http://127.0.0.1:5222/http-bind/"