Questions tagged as 'javascript'

4
answers

How to get only the numbers of a string in Javascript?

I would like to know if there are functions that return only the numeric values of a string, if any, which is the simplest and most efficient way to implement? Example: apenasNumeros("5tr1ng"); Result:    51     
asked by 01.02.2014 / 13:17
1
answer

How does Symbol work in ES6?

In the new Javascript specification ECMAScript (ES6) was created a new primitive type called Symbol() what is its usefulness? / p>     
asked by 02.12.2015 / 20:41
1
answer

ASP.NET MVC - Attribute that writes to a View

I need to write a Attribute that writes a mask validation to View. For example, I would like to mark a property in the Model with a [CEP] , write the following in the View: <script type='text/javascript'> $(docu...
asked by 17.03.2014 / 23:59
3
answers

How to randomly color DIVs with a color Array in javascript?

I created a function that exchanges colors (pulled from an array ) in certain elements of the page (which are also in array ), changing the colors of the elements one after another. I wanted to do something different, like: Sort the element an...
asked by 14.02.2014 / 15:39
4
answers

Force javascript file update without disabling cache

In a large-scale web application that develops, an upset occurs every time updates occur, because browsers, especially Google Chrome, cache JavaScript files and, sometimes, incompatibilities occur between the server code and the client code, l...
asked by 10.06.2015 / 02:49
5
answers

What is the difference between substr and substring?

I want to know the difference between alert("abc".substr(0,2)); and alert("abc".substring(0,2)); Both seem to produce "ab".     
asked by 31.10.2018 / 20:54
3
answers

How to observe an error in the iframe element with attribute "sandbox"

I have in my document a iframe with the sandbox attribute. With javasript I read a Markdown file and parse using the showdonwjs library and add this result to attribute srcdoc of iframe and result is expe...
asked by 26.10.2016 / 08:39
3
answers

Global variable in JavaScript

How to make a global variable in JavaScript? I need the variable that was declared in one function to work in another function. Example: JSFiddle $("#div3").click(function() { var fill = "a"; }); $("#div2").click(function() { ale...
asked by 12.09.2014 / 00:10
3
answers

Why is it wrong / bad to repeat an HTML ID?

I think the title says it all, why is it wrong to repeat HTML IDs? I notice lots of people doing things like: <div id="foo">bar</div> <div id="foo">baz</div> To apply CSS and understand the problems that this caus...
asked by 27.07.2018 / 17:10
2
answers

Working with websockets

I'm trying to use WebSockets in PHP and Javascript and I'm confused, it uses the ws: // and wss: // protocol and the hostgator ) do not have these protocols enabled (I think!) and I can not connect, does anyone know if I need to enable these...
asked by 05.06.2014 / 21:39