Tag: JavaScript

在IE浏览器中的HTML分析器问题

我试图创build一个对话框,只有当浏览器selectIE浏览器(任何版本)才会出现,但我得到这个错误: 消息:HTML分析错误:无法在子元素closures之前修改父容器元素(KB927917) 这一切都在“行/字符/代码”0,所以我不知道错误在哪里。 我使用的代码是这样的: <script type="text/javascript"> <!– if(BrowserDetect.browser.contains("Explorer")) { var Nachricht = 'Hemos detectado que está utilizando ' + BrowserDetect.browser + ' ' + BrowserDetect.version + '. Puede que algunas funciones no estén habilitadas. <p></p> Si desea experimentar todo el potencial del portal, por favor intente desde otro navegador (browser). <p></p>Gracias showDialog('¡Aviso Importante!',Nachricht,'warning',10); } </script> […]

将“canvas”图像数据上传到服务器

我需要将canvas图像数据上传到服务器(数据库),即我需要创build一个表单和一个input=文件,并发布图像数据没有任何用户交互。

从上下文获取canvas

有什么办法来获得上下文的canvas? 为什么我要问的是因为我正在为CanvasRenderingContext2D创build一个原型函数,其中我需要canvas元素的宽度/高度。 例如: var cv = document.getElementById('canvas'); var ctx = cv.getContext('2d'); // Using only 'ctx', how to get 'cv'?

用JavaScript添加类

我正在写一些香草JavaScript来创build一个不错的导航菜单。 我坚持添加一个活跃的类。 我通过类名获取元素不是由id。 下面的代码工作,如果用id代替,但是,我需要它适用于多个元素。 HTML <img class="navButton" id="topArrow" src="images/arrows/top.png" /> <img class="navButton" id="rightArrow" src="images/arrows/right.png" /> JS var button = document.getElementsByClassName("navButton"); button.onmouseover = function() { button.setAttribute("class", "active"); button.setAttribute("src", "images/arrows/top_o.png"); } 请不要包含jQuery的答案。

如何使用JSON.NET通过ASP.NET MVC传递JSONdate值?

可能重复: 格式化Microsoft JSONdate? ASP.NET函数Json()格式化并返回一个date {"d":"\/Date(1240718400000)\/"} 必须在客户端处理,这是有问题的。 对于来回发送date值的方法,您有什么build议?

find什么JavaScript更改DOM?

最近我一直在和其他的JS一起工作,并开始非常讨厌试图debugging它。 即使使用Chrome的开发工具,我也无法追踪页面加载过程中发生的很多DOM变化。 有什么工具可以告诉我哪些部分的DOM(比如一个附加的属性)是由JS完成的吗? 谢谢

有效的会话超时和pipe理

有没有办法使用Angularjspipe理用户会话?我的意思是:: 会话超时 – 系统空闲时。 会话即将到期时发出警报,并select恢复会话。 如果会话已过期,则尝试发出请求时redirect(或任何其他操作)。 拦截器可以解决这个问题吗? 你能提供一个例子吗? 提前致谢。

HTML5 data- *属性types转换string和数字

为什么data-value="2.0"的值被强制转换为String,而data-value="2.5"强制转换为Number? 我可以在我的function内处理这个罚款。 我只是想更多地了解Javascript如何处理数字和string。 这种情况让我措手不及。 <a data-value="2.0">2.0</a> <a data-value="2.5">2.5</a> $("a").click(function() { alert(typeof $(this).data( "value")); }); [小提琴]

使用Angular JS向其他模块configuration注入常量

我想在整个应用程序中共享一些variables,如基本path。 这些variables需要在模块configuration期间进行访问。 我的意见是,我可以使用一个常数或提供者。 我有几个模块,每个模块都有自己的路由configuration。 在这些路由configuration中,我想访问一些设置,例如。 这适用于应用程序模块configuration,但不适用于其他模块configuration(对于其他模块的控制器),我总是会得到“未知提供者:来自myApp.orders的信息”。 var myApp = angular.module('myApp', ['myApp.orders']); myApp.constant('info', { version : '1.0' }); myApp.config(function(info) { console.log('app config: ' + info.version); }); myApp.controller('MyController', function (info) { console.log('controller: ' + info.version); }); var orders = angular.module('myApp.orders', []); // Remove comments to see it fail. //orders.config(function(info) { // console.log('orders config: ' + info.version); //}); […]

javascript onbeforeunload不显示自定义消息

我有onbeforeunload事件的自定义消息,并运作良好,但我今天注意到,它不再显示我的消息。 而是显示“您所做的更改可能无法保存” window.onbeforeunload = function () { return 'Custom message' } 任何人都可以请让我知道如何解决它?