2013年9月26日 星期四
javascript 執行減法運算
在 javascript 執行 float 相減時,可能會發生 9.700000000000001 的情形
為防止這個情形發生,必需加上 .toFixed()
例如:
var i = 9.8;
i = (i - 0.1).toFixed(1); // i => 9.7
2013年8月14日 星期三
Get viewport size (Nice)
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
alert(x);
alert(y);
Reference url: http://stackoverflow.com/questions/3437786/how-to-get-web-page-size-browser-window-size-screen-size-in-a-cross-browser-wa
2013年7月31日 星期三
Post data to a new window with full screen
Javascript Example:
function postDataToNewWindow() {
var myform = document.createElement("form");
myform.setAttribute("method", "post");
myform.setAttribute("action", "verifyCredential.asp");
myform.setAttribute("target", "_custom");
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", "credential");
hiddenField.setAttribute("id", "credential");
hiddenField.setAttribute("value", "2.0");
myform.appendChild(hiddenField);
document.body.appendChild(myform);
window.open("", "_custom", "fullscreen=yes");
myform.submit();
}
function postDataToNewWindow() {
var myform = document.createElement("form");
myform.setAttribute("method", "post");
myform.setAttribute("action", "verifyCredential.asp");
myform.setAttribute("target", "_custom");
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", "credential");
hiddenField.setAttribute("id", "credential");
hiddenField.setAttribute("value", "2.0");
myform.appendChild(hiddenField);
document.body.appendChild(myform);
window.open("", "_custom", "fullscreen=yes");
myform.submit();
}
訂閱:
文章 (Atom)