不能在WinJs中用alert! 用console代替
2012-11-28 14:14
141 查看
Thankfully there is a JavaScript console available in Visual Studio so you can simply call
console.log(). The following steps will take you that far:
感激地是这有一个js的console在VS中可以实现,所以你可以直接用console.log().下面的步骤会带你体会:
1. Create a new JavaScript (Blank Application) Project in VS11 Express.
1.创建一个新的JS项目在VS11中。
2. Add an element to your default.html page providing something to click on. You could go with boring old text, but I went for a leaf image (pictured above, download)
and i gave it an ID of “leafImage”.
2.添加一个元素到你的default.html页面以提供一个东西去点击。你可以用无聊的文本,但是我想用一个叶子的图片,然后我给它一个名为“leafImage”的ID。
3. Next add an event handler in the onmainwindowactivated function in default.js. You can remove the ActivationKind check as it doesn’t matter for this sample. Now when adding the eventHandler I skipped over ‘click’ and instead attached
to ‘MSPointerDown’ fully embracing the new Input system of Windows 8:
3.接下来在default.js的函数onmainwindowactivated中添加一个事件处理程序。你可以删除ActivationKind检验,因为它对于这个例子没多大影响。现在,当添加eventHandler我跳过了“点击”,而是连接到“MSPointerDown“完全接受新的输入系统。
default.html页面:
leafImage.addEventListener('MSPointerDown',
function(){
//alert('leaf pointerdowned');
console.log('leaf pointerdowned');
});
default.js页面:
leafImage.addEventListener('MSPointerDown',
function(){
//alert('leaf pointerdowned');
console.log('leaf pointerdowned');
var
md =
new Windows.UI.Popups.MessageDialog('Ready
for Monday?');
var
result,
resultOptions =
['Oh yeah!',
'Nooooo!'];
var
cmd;
for(var
i =
0;
i <
resultOptions.length;
i++)
{
cmd
= new
Windows.UI.Popups.UICommand();
cmd.label
= resultOptions[i];
cmd.invoked
= function(c)
{
result
= c.label;
}
md.commands.append(cmd);
}
md.showAsync().then(function
(c)
{
console.log('answer: '
+ result);
});
});
console.log(). The following steps will take you that far:
感激地是这有一个js的console在VS中可以实现,所以你可以直接用console.log().下面的步骤会带你体会:
1. Create a new JavaScript (Blank Application) Project in VS11 Express.
1.创建一个新的JS项目在VS11中。
2. Add an element to your default.html page providing something to click on. You could go with boring old text, but I went for a leaf image (pictured above, download)
and i gave it an ID of “leafImage”.
2.添加一个元素到你的default.html页面以提供一个东西去点击。你可以用无聊的文本,但是我想用一个叶子的图片,然后我给它一个名为“leafImage”的ID。
3. Next add an event handler in the onmainwindowactivated function in default.js. You can remove the ActivationKind check as it doesn’t matter for this sample. Now when adding the eventHandler I skipped over ‘click’ and instead attached
to ‘MSPointerDown’ fully embracing the new Input system of Windows 8:
3.接下来在default.js的函数onmainwindowactivated中添加一个事件处理程序。你可以删除ActivationKind检验,因为它对于这个例子没多大影响。现在,当添加eventHandler我跳过了“点击”,而是连接到“MSPointerDown“完全接受新的输入系统。
default.html页面:
leafImage.addEventListener('MSPointerDown',
function(){
//alert('leaf pointerdowned');
console.log('leaf pointerdowned');
});
default.js页面:
leafImage.addEventListener('MSPointerDown',
function(){
//alert('leaf pointerdowned');
console.log('leaf pointerdowned');
var
md =
new Windows.UI.Popups.MessageDialog('Ready
for Monday?');
var
result,
resultOptions =
['Oh yeah!',
'Nooooo!'];
var
cmd;
for(var
i =
0;
i <
resultOptions.length;
i++)
{
cmd
= new
Windows.UI.Popups.UICommand();
cmd.label
= resultOptions[i];
cmd.invoked
= function(c)
{
result
= c.label;
}
md.commands.append(cmd);
}
md.showAsync().then(function
(c)
{
console.log('answer: '
+ result);
});
});
相关文章推荐
- Windows不能在本地计算机启动OracleDBConsoleorcl
- ERP与BPR有联系但不能互相代替
- windows不能在本地启动OracleDBConsole
- 基于jQuery的窗口插件:jMessageBox 代替alert,confirm
- 写了一个打印信息的函数比Alert强大,类似Firebug中的console.table
- 关于自定义AlertDialog,设置不能充满全屏的解决方法
- oracle--Windows不能在本地计算机启动OracleDBConsoleorcl .错误代码1
- div代替window.alert,让这个div显示信息后,在指定之间时间内消失
- alert跟console.log()的区别
- Asp.net中用来代替Response.Write("<script>alert('错误信息');</script>");
- Windows不能在本地计算机启动OracleDBConsoleorcl
- 使用blockUI制作自定义的漂亮的网页提示框(代替confirm和alert)
- javascript中使用console与alert调试的差别
- [读书笔记]第一章 伴郎伴娘长得再漂亮,也不能代替新人入洞房
- ubuntu下 如何解决rubyEE安装后 ./script/console不能使用的问题
- USB 作为一种通用的串行通信规范,为何在电子通信里不能完全代替 RS-232 串口?
- 解决OracleDBConsoleorcl不能启动
- weblogic 11 console不能登录问题
- Oracle10g 解决在ip或者机器名更改后的console em 不能使用的问题
- 告别alert,拥抱console