Skip to content

ThirteeNov

My personal blog about coding and internet

Menu
  • About me
  • About Zofia Kreasi
  • Cart
  • Checkout
  • Making an airplane game from scratch in Unity
  • My account
  • Privacy Policy
  • Privacy Policy – zkLeaderboard
  • Sample Page
  • Shop
  • Tutorials on Learning JavaScript
  • ZKAccounts – Privacy Policy
Menu

How to display currency exchange quote from Yahoo Finance with JavaScript

Posted on May 6, 2017August 4, 2020 by Habibie

In this tutorial I want to show you how to retrieve currency exchange rate quote from Yahoo Finance using JavaScript.

This price quote is updated every second. The script is originally provided by: https://gist.github.com/henrik/265014

Here is the source code:

<DOCTYPE html>
<html>
	<head>
		<title>FXSpeculate</title>
	</head>
	<body>	
		<p id="gbpusd"></p>
		<script>
			var GBPUSD, GBPUSDrate;
			function parseExchangeRateGBPUSD(data) {
				GBPUSD = data.query.results.row.name;
				GBPUSDrate = parseFloat(data.query.results.row.rate, 10);
				document.getElementById("gbpusd").innerHTML =  "Rate for "  + GBPUSD + " is: " + GBPUSDrate;
			}
			function updateGBPUSD(){
				var script = document.createElement('script');
				script.setAttribute('src', "http://query.yahooapis.com/v1/public/yql?q=select%20rate%2Cname%20from%20csv%20where%20url%3D'http%3A%2F%2Fdownload.finance.yahoo.com%2Fd%2Fquotes%3Fs%3DGBPUSD%253DX%26f%3Dl1n'%20and%20columns%3D'rate%2Cname'&format=json&callback=parseExchangeRateGBPUSD");
				document.body.appendChild(script);
			}
			updateGBPUSD();
			setInterval(function(){
				location.reload();
			}, 1000);
		</script>
	</body>
</html>
Post Views: 343
ciihuy2020

Welcome!

  • My YouTube Channel
  • My GitHub Page
  • About me

Categories

  • 3DVista
  • Android
  • Apache
  • C#
  • Cordova
  • Electron & Node JS
  • HTML5, CSS & JavaScript
  • iOS
  • Let's Make Unity Games
  • Misc
  • Photoshop
  • PHP
  • Python
  • Uncategorized
  • Unity
  • WordPress

Recent Posts

  • Hover Reveal script for Unity to show and hide object on mouse hover
  • How to Prevent UI Clicks in Unity from “Bleeding Through” to 3D Objects Behind Them
  • Make objects like wires and cables easily in Unity using Ciihuy Curved Mesh
  • [SOLVED] Can’t Add Custom Domain to Blogger After Losing CNAME Verification
  • iOS App Icon Generator by CiihuyCom
© 2026 ThirteeNov | Powered by Superbs Personal Blog theme