Posts by Klaider • 2,509 points
154 posts
-
1
votes3
answers214
viewsA: Javascript Check if it is safe
I would like to know , if the code below offers some insecurity to the site. ... If yes, what is the safe way to write this code ? You already know that the eval causes the browser to…
-
2
votes3
answers1883
viewsA: Bind Javascript
Function#bind(instância, ...argumentos) returns a function, which calls another function, with instance and arguments memorized (including that can still be passed + arguments when calling it). It…
javascriptanswered Klaider 2,509 -
0
votes1
answer145
viewsA: How to step a database variable that is in php for javascript?
That’s not how it works: passing a "variable" from one code running to another (and that still works totally different from each other, even more by a request). An AJAX (asynchronous) request is…
-
1
votes4
answers1129
viewsA: Last Child of Element Chain
For now there is no direct native way to get the element inside containers "nested". For now you can have a consumable method: (I warn you that I will not implement this method within HTMLElement#…
javascriptanswered Klaider 2,509 -
0
votes3
answers216
viewsA: Why is the behavior of the undefined variable different from the undefined property?
I don’t know exactly why it works like this, but what I’ve noticed is that the exception of an undefined variable helps us find out if it exists or not, whether it’s global or local. try { aa }…
-
0
votes2
answers205
viewsA: Receive data in Javascript
I based a little on the reply of @Sergiobarros. This solution will, before taking the parameters of the URL, take the fragment from it, then take the list of parameters, and finally build a…
-
0
votes2
answers53
viewsA: How to prevent loading a Javascript library more than once
First, as my comment says, you do not lose instance of a class if it is reset to an identifier or property, for example: class A { method() {} } let instance = new A A = null instance.method //…
-
1
votes3
answers1306
viewsA: Empty string passed to getElementById()
I believe that jQuery may have a role with some other features of the browser when it will interpret the query of the first parameter of $(query) -> jQuery(query) -> $.fn.find(query), etc.,…
-
0
votes2
answers74
viewsA: Script to recover client
Called "Confirmation", browsers implement the global method confirm(mensagem). This method for the execution of the page, ie, is synchronous, after you receive the response from the client that the…
-
2
votes1
answer810
viewsQ: What is the need for __proto__?
What is the need for "__proto__" on an object? I just did some tests and realized that "__proto__" is not a property, but can be indexed. When I define a property in x object, this property is also…
javascriptasked Klaider 2,509 -
6
votes3
answers1615
viewsA: Innerhtml does not work
Only 2 errors in Javascript code: var test document.getElementById("valores");: After 'var test' could have been declared '=' (initializer), ',' (next variable), ';' or a line break, but instead a…
javascriptanswered Klaider 2,509 -
0
votes2
answers104
viewsA: How does this function work within for?
The loop for(;;) does not have its own scope, and because of this this function creates a new scope, re-generating the i as an argument. The argument i within the scope of that function will remain…
-
2
votes3
answers89
viewsA: Error calling a secondary method via CALLBACK: Uncaught Typeerror: Cannot read Property 'secondarily named' of Undefined
How to call via callback, a method of a class, where this method uses other methods? If you intend to reference test_objeto.metodoPrincipal without passing test_objeto for chamaViaCallback, use the…
-
0
votes1
answer288
viewsA: Using Ajax in the navigation of the entire site has a problem?
The question may be wrong on the first point: "I don’t want you to update every page exchange, because that for playback", the page keeps running if the HTTP request being made is asynchronous, and…
-
3
votes2
answers3526
viewsQ: Why is 'ç' converted to %C3%A7 URL, not %E7?
When I was coding the 'ç' character for the query format (where the parameters are) of the URL, I got: %C3%A7 % specifies a hexadecimal byte, but why almost all characters (including 'ç') should be…
-
1
votes1
answer34
viewsA: Does using libs as jQuery negatively influence a page’s loading performance/time?
What most influences the loading of the page is the synchronous request of the file. These factors may also influence very little: Interpret the code; Run the code. While the code (without the…
-
0
votes2
answers162
viewsA: How to delete a selectbox with Javascript one by one
If you are able to get a list with each element "select" that you created, use the method $.fn.remove. This will remove each element (from the page) you have in an instantiated object from the…
-
1
votes1
answer98
viewsQ: How to access variables from a previous scope in PHP?
First, within a class I have a method, in that method I have a parameter (for now) and declare some variables in its scope. Therefore, I also declare functions within the scope of the method, and as…
-
2
votes1
answer89
viewsA: Validation Issues Upload Multiple Javascript Files
DOM-based objects usually have events that can be notified in two ways: assigning the property ("on" + windName) with a function reference; using the method object.addEventListener(nomeDoEvento,…
-
3
votes3
answers259
viewsA: Javascript - Make <article> appear by clicking on a <li>
The question looks more like a request, so I will answer only with an example code :p var defaultArticle var articles$ = {} articles$[defaultArticle = "CARD"] = $("#CARD") articles$.SLIP =…
-
0
votes2
answers149
viewsA: Get multiple field values
If the posting parameters are declared in the attribute name element of each field of your form, you can use the method $.fn.serialize (commented by @Zuul). The method will return a usable URL text…
-
2
votes1
answer1911
viewsA: What is the setRequestHeader method for in pure AJAX in POST mode?
XHR().setRequestHeader serves to set a header in the request headers list. When you call it that way: xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") you are setting the…
-
1
votes1
answer197
viewsA: HTML snippet as parameter of a javascript function
If you set the "click" anchor callback on <script*src=*>*</script> you will never have to face script-inline problems. Your problem should be related to quotation marks, it is possible…
-
2
votes2
answers317
viewsA: Problems with jQuery printing function
Just stop calling the function you declared in the first parameter of $.fn.ready. And now you could call this.print in that function block. In jQuery, this "ready" event happens when each element of…
-
1
votes3
answers779
viewsA: Assigning an image(s) value to the Javascript input
So you want to pass multiple images to the URL? In addition to doing this, you’ll need to go through each one in the code next to the server. One way to do this is to create parameters in the URL…
-
2
votes2
answers373
viewsA: How to add class in jQuery to a particular element?
You only need to cross each li (Oops! a) until you find one of them that contains a href equal to the location.pathname. Therefore, there is a better way to do this if you re-interpret the href of…
-
2
votes2
answers246
viewsA: String Comparison Problem in AJAX
You’re not having a problem with comparison, you’re having a problem with feedback. Currently your request is asynchronous, so it makes no sense for you to return data about it directly in the code.…
-
8
votes1
answer110
viewsQ: How to find out the rendered size of a curve in Html5 canvas 2d?
I need to figure out the rendered size of a curve on canvas 2d context.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y); with this code, for example // pontos de controle var cp1x = 200, cp1y = 150, cp2x…
-
1
votes2
answers236
viewsA: Avoiding conflicts between variables in Javascript
Have a reference of this to be used in another scope where there is another this does not generate conflicts. It is never necessary for the browser to make a reference to this call another this.…
-
5
votes2
answers1014
viewsA: How to copy a canvas to an image
Do not confuse an image object with a 2d context of the canvas. The only one that can be changed in an HTML image is its source (Image().src). Continuing, it will be simpler to do what you want: You…
-
0
votes2
answers161
viewsA: Searching a javascript array
It’s okay to use Array().indexOf, this is the only way to discover the index of a specific element in a Array, walking herself. Therefore, you could make a polyfill to work on all browsers. Edit: I…
-
0
votes2
answers1368
viewsA: Change color of input color
A simple answer like the question: In this code the only thing I did was update the value of "input[type=color]" using the events oncut, onkeyup, ... of HTMLInputElement. I added a few extra things.…
-
1
votes1
answer20
viewsA: Preview input field does not work
I noticed that you are passing a list of jQuery elements to the function readImage. readImage($(this)); You just need to stop covering this with the $ jQuery. If you haven’t noticed, this is a…
-
0
votes3
answers1178
viewsA: Apply class with innerHTML
It is impossible to apply a class to its element 'td' re-assigning innerHTML, whereas it is only the HTML interior of you. outerHTML that would be correct, therefore it would be laborious and…
-
1
votes4
answers175
viewsA: Comment element ID attribute
Possible is not in all browsers as they remove comments from tags. Commenting on the attribute is dangerous as it is necessary to modify the outerHTML of its element, which ends up…
-
3
votes1
answer177
viewsA: Loading gif screen on html page loading
There are several ways to do this, but it is common to have a container visible on the page, which is removed until the document loads completely (it may be different according to the type of…
-
0
votes1
answer35
viewsA: Code reduction and variable declaration
Yeah, with a loop. Note: You may need to create a list to represent objects with numbers (I still have no idea what an "owlCarousel" and "Owl" would be"). In this code I do not create a variable for…
-
0
votes1
answer31
viewsA: Hide all different contents from the selected
What I noticed was that: you forgot to display the elements equal to self; and that you are always alternating the class "hidden", which may end up making elements that were to be invisible as…
-
3
votes2
answers1038
viewsA: Change the div border and at the same time show the value in another HTML tag
You forgot to define the type of measure in 'borderRadius'. You may declare 'px' in front of the amount you will declare. (Now that I went to see the @Andrewribeiro remark (I didn’t notice much…
-
0
votes3
answers520
viewsA: List array according to what was selected
Basically there are some problems in the code for(i = 0; i <= nome_array.length; i++){ This will cause the loop to run +1 time than expected because (assuming nome_array.length were 10: 10 <=…
-
3
votes2
answers874
viewsA: Confirm before submitting javascript function
The function displayAlertify returns nothing. *expanded comment code* function displayAlertify(message) { /* escopo anterior */ alertify.confirm(message, function(e) { /* novo escopo */ if (e) { /*…
-
2
votes2
answers220
viewsQ: How to create an object with two or more instances in Javascript?
In Javascript I know that it is possible to create an instance of a class using 'new' new Classe And how to create an object that is instance of several classes? For example new Classe,…
-
2
votes3
answers1431
viewsA: Hide object with Javascript
I noticed that some of your Libraries are modifying the HTML elements, including "form#form-tab-1". Maybe the element is losing its styles online. I can’t say, but your library(s) (ies) can (ssam)…
-
1
votes1
answer453
viewsA: with capturing the width of the printing screen with jQuery
Still can’t know print screen information on JS, so even you can’t capture the print screen width on jQuery. Something you can do is use @media queries of CSS3 and make page changes according to the…
-
0
votes1
answer318
viewsA: Create image blob in PHP
If you are converting the URL image to its normal version you may be including the header "data:image/*;base64,", It will end up preventing the image from being read, as well as being unnecessary.…
-
2
votes2
answers314
viewsA: generating an array of [month/year] p/ send to an ajax
Just like @Tobymosque said, so if you want to iterate dates sequentially, you can do so: var dates = {}; for (var key in val) { var index = key.indexOf("/"), year = key.substr(index + 1); /* checa…
-
3
votes1
answer49
viewsA: error with arlert function that I created
That’s what’s going on: <script> alert('Pedido finalizado'); </script> To solve this the \ would have to be escaped with a \. Alert("Pedido \\n finalizado"); And so: <script>…
-
3
votes2
answers217
viewsQ: How to capture the status (and readyState) of the IE6 XHR?
Like? alert(new ActiveXObject("Microsoft.XMLHTTP").readyState); // undefined // 0 alert((new XMLHttpRequest).readyState); // 0 Edit: in my code, before I had modified the this for xhr in the scope…
-
1
votes1
answer2643
viewsA: Open multiple tabs on a Javascript link
It is no longer possible to do this in recent browsers or containing popup blocker, so if window.open(...) do not return an object or return undefined or null, you can know if the same popup has…
-
0
votes2
answers85
viewsA: My userscript does not work
The main problem is because you are searching elements for multiple classes directly using document.getElementsByClassName. Use document.querySelector instead of this method. And instead of using…
javascriptanswered Klaider 2,509