Last active
August 29, 2015 14:01
-
-
Save blueskyarea/d7c5c2f78234480a4971 to your computer and use it in GitHub Desktop.
javascript sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>jsonで外部スクリプトファイルにデータ渡す</title> | |
<script type="text/javascript" src="json_test.js"></script> | |
<script type="text/javascript"> | |
var items = { | |
num: 10, | |
character: "a", | |
characters: "abc", | |
bool: true | |
}; | |
</script> | |
</head> | |
<body> | |
<h2>jsonで外部スクリプトファイルにデータ渡す</h2> | |
<input type="button" value="テスト" onclick="test()"> | |
<div id="output"></div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// javascript | |
function test(){ | |
// データの取得 | |
var num = items.num; | |
var character = items.character; | |
var characters = items.characters; | |
var bool = items.bool; | |
// データの出力 | |
var html = "num=" + num + "<br>" + | |
"character=" + character + "<br>" + | |
"characters=" + characters + "<br>" + | |
"bool=" + bool; | |
document.getElementById("output").innerHTML = html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment