What does "!function () {}" mean/do in javascript?

Possible Duplicate: What does the exclamation mark do before the function? ! preceding function in javascript? javascript function leading bang ! syntax I've been seeing this pattern a little bit recently in javascript: !function () { // do something }() what does the bang in front of the function keyword supposed to do? I can't seem to find anything about it on the inter

“!function(){}”是什么意思/在JavaScript中做?

可能重复: 该功能之前感叹号做了什么? ! 前面的函数在javascript中? JavaScript功能领先砰! 句法 我最近在javascript中看到了这种模式: !function () { // do something }() 在关键字function前应该做什么? 我似乎无法在intertubez上找到任何有关它的信息。 function () { // do something }(); 这是一个立即调用的函数声明。 函数声明不能​​立即调用; 这是一个语法错误。 为了避免这种语法错

Image flicker and prevention. Proper coding standards

I've been working with some basic animations lately and trying to follow good web practices at the same time. The problem I'm encountering is image flicker when not using a preset css method to hide the element before the page loads. It's very easy to prevent the flicker by just hiding the element with my normal css and then revealing it with javascript, but that seems to me a horr

图像闪烁和预防。 适当的编码标准

最近我一直在处理一些基本的动画,并试图在同一时间遵循良好的网络实践。 我遇到的问题是在页面加载之前不使用预设的css方法隐藏元素时图像闪烁。 只需用我的普通css隐藏元素,然后用javascript显示它就很容易防止闪烁,但在我看来,如果有人禁用javascript,那在我看来这是一种可怕的做法。 我是否应该使用将<noscript>标记放在标题中的HTML5功能,然后使用单独的样式表将不透明度和位置设置为没有javascript的用户

How can call a selected class on window.onload

I have made a simple javascript which during window.onload fades in the body when finished. I want to create an overlay with a specific class instead which shall do the reverse. I want the overlay to simply fade out and after the animation the object would be destroyed or set as display:none . <style> body { opacity: 0; transition: opacity 500ms ease-in-out; } </style>

如何在window.onload上调用选定的类

我做了一个简单的JavaScript,在window.onload完成时,在body中淡入淡出。 我想创建一个具有特定类的覆盖层,而不是相反。 我希望覆盖层只是淡出,动画之后对象将被销毁或设置为display:none 。 <style> body { opacity: 0; transition: opacity 500ms ease-in-out; } </style> <script>window.onload = function() {setTimeout(function(){document.body.style.opacity="100";},500);};</

Prevent to load a page with js disabled

It's possible to disable an entire page html if the js is disabled on the browser of the user? EDIT: Thank you all for the answers and comments! However, what I mean is: I want that the page is replaced with something else, like an image, in that case. The noscript tag defines an alternate content for users that have disabled scripts in their browser or have a browser that doesn't

防止加载禁用js的页面

如果在用户的浏览器上禁用了js,可以禁用整个页面html? 编辑: 谢谢大家的回答和评论! 但是,我的意思是:在这种情况下,我希望将页面替换为其他内容,如图像。 noscript标签为已在其浏览器中禁用脚本或具有不支持脚本的浏览器的用户定义了备用内容。 你可以在你的html主体中做这样的事情来显示你想显示的任何图像: <noscript> <style type="text/css"> .wrapper {display:none;} </

How can I make the browser wait to display the page until it's fully loaded?

I hate how you can actually see webpages load. I think it'd be much more appealing to wait until the page is fully loaded and ready to be displayed, including all scripts and images, and then have the browser display it. So I have two questions... How can I do this? I'm a total noob to web development, but is this common practice? If not, why? Thanks in advance for your wisdom!

如何让浏览器等待显示页面,直到完全加载?

我讨厌你如何看到网页加载。 我认为等待页面完全加载并准备好显示,包括所有脚本和图像,然后让浏览器显示它会更有吸引力。 所以我有两个问题... 我怎样才能做到这一点? 我是一个网页开发的总不愿意,但这是常见的做法? 如果不是,为什么? 预先感谢您的智慧! 由于所有原因,这是一个非常糟糕的主意,等等。 这就是说,以下是你如何使用jQuery来做到这一点: <body> <div id="msg" style="font-size:lar

javascript usage in html tag

This question already has an answer here: What is the purpose of the HTML “no-js” class? 6 answers There is no JavaScript there. Those are conditional comments: a hack supported by old versions of IE that misapplied HTML's comment syntax to do browser detection. Further reading: wikipedia quirks mode msdn

html标签中的javascript用法

这个问题在这里已经有了答案: HTML“no-js”类的目的是什么? 6个答案 那里没有JavaScript。 这些是有条件的评论:旧版IE支持的黑客错误地使用HTML的注释语法来执行浏览器检测。 进一步阅读: 维基百科 怪癖模式 MSDN

JS number function adds up zeros at the end

This question already has an answer here: Javascript summing large integers 6 answers In JS, the largest integral value is 9007199254740991 That is, all the positive and negative integers should not exceed the -9007199254740991 and 9007199254740991 respectively. The same is defined as the 253-1. console.log(Number.isSafeInteger(parseInt('1111111111'))) console.log(parseInt('1111111111'))

JS数字函数在最后加上零

这个问题在这里已经有了答案: Javascript总结大整数6个答案 在JS中,最大的整数值是9007199254740991也就是说,所有的正整数和负整数分别不应该超过-9007199254740991和9007199254740991 。 同样的定义为253-1。 console.log(Number.isSafeInteger(parseInt('1111111111'))) console.log(parseInt('1111111111')) console.log(Number.isSafeInteger(parseInt('111111111111111111'))) console.log(parseInt('111111111

How to update javascript array if item exists in that index position?

Pretty new to jQuery and JavaScript so please be gentle... I am working on a POC to create a "column mapping" page where the user is able to drag and drop a list of "column headers" to a grid of new column headers. I need to build an array that I can send back to a SQL database. I have this part (mostly) functioning how I would like. When the item is dragged from the col

如果项目存在于该索引位置,如何更新javascript数组?

jQuery和JavaScript相当新颖,所以请温和... 我正在处理POC以创建一个“列映射”页面,用户可以在其中将“列标题”列表拖放到新列标题的网格中。 我需要构建一个可以发送回SQL数据库的数组。 我有这部分(大部分)运作我想要的。 将项目从左侧的列列表拖到右侧的标题网格中时,如果项目存在,代码应更新/替换该索引处的数组项目。 如果该项目不存在,它应该将该项目添加到数组中。 例如:如果您将“名字”拖到“标题”,则应将

onmousemove event does not fire from within external source?

I am loading up an external webpage (ie www.duckduckgo.com in this example) within a div on my webpage. I want to get my mouse X and Y position while within and outside the div, but when I am inside the div, it seems that the webpage blocks the onmousemove event from firing. However, the onmouseover event fires only once when entering the div. Here is example code that illustrates my problem:

onmousemove事件不会从外部源中触发?

我在我的网页上加载了一个外部网页(例如www.duckduckgo.com)。 我想在div内外获取鼠标的X和Y位置,但是当我在div内时,网页似乎阻止了onmousemove事件发生。 但是,在进入div时, onmouseover事件只会触发一次。 以下是说明我的问题的示例代码: function mouseEvent(event) { var x = event.clientX; var y = event.clientY; document.getElementById('label').innerHTML = 'X=' + x + ' Y=' + y;

Origin is not allowed by Access

I'm making an Ajax.request to a remote PHP server in a Sencha Touch 2 application (wrapped in PhoneGap). The response from the server is the following: XMLHttpRequest cannot load http://nqatalog.negroesquisso.pt/login.php. Origin http://localhost:8888 is not allowed by Access-Control-Allow-Origin. How can I fix this problem? I wrote an article on this issue a while back, Cross Domain

Access不允许使用Origin

我正在向Sencha Touch 2应用程序中的远程PHP服务器(包装在PhoneGap中)中创建一个Ajax.request 。 服务器的响应如下: XMLHttpRequest无法加载http://nqatalog.negroesquisso.pt/login.php。 Access-Control-Allow-Origin不允许源http://localhost:8888 。 我该如何解决这个问题? 我在前面写了一篇关于这个问题的文章,Cross Domain AJAX。 如果控制了响应服务器,最简单的方法就是为以下内容添加响应标头: Access