[javascript]YAHOO股市的營收表查詢小工具

YAHOO股市的營收表比較一目了然,所以想編輯一個小工具,可以直接輸入股號跳出YAHOO股市對應股票的營收表。
使用JavaScript 標準的開啟新視窗語法window.open(“URL”, “name”, “specs”, “replace”);
window.open 的第一個參數”網址”是必要項目,window.open參考資料

<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>earning</title>
    <script>
        function stock_earning() {
        	var stock_num = document.getElementById("stock_num").value;  
        	window.open('https://tw.stock.yahoo.com/d/s/earning_'+stock_num+'.html', 'YAHOO');
        }

    	function ready(){
    		var input = document.getElementById('stock_num');
    		input.addEventListener('keyup', function(event){
    			event.preventDefault();
    			if (event.keyCode === 13) {
    				stock_earning();
				}
    		});
		}
    </script>
</head>
<body onload="ready();">
   	<P>股票營收表</P>
    <input type="text" placeholder="股號" name="stock_num" id="stock_num">
    <button type="button" onclick="stock_earning()">查詢</button>
</body>
</html>

Yahoo股市_股票營收表查詢

You may also like...

留言