There is website that alerts you with a text according to what you have done in the page.
I want to read that message with JavaScript so I can write some code according to what the page have shown in the popup text.
alert("message");
I just need to know what the "message" is!
The website that I'm trying to get message from is coded with asp.What should I do with that if it's impossible to read the message with JS.
There is website that alerts you with a text according to what you have done in the page.
I want to read that message with JavaScript so I can write some code according to what the page have shown in the popup text.
alert("message");
I just need to know what the "message" is!
The website that I'm trying to get message from is coded with asp.What should I do with that if it's impossible to read the message with JS.
Share Improve this question edited Nov 12, 2016 at 19:43 Explosion asked Nov 12, 2016 at 15:37 ExplosionExplosion 5985 silver badges14 bronze badges 3- 1 You cannot. Just record action and save it – Rajesh Commented Nov 12, 2016 at 15:38
- 2 Why would you want to record this? If you want to modify some site's functionality, this is not how you go about it. – xyz Commented Nov 12, 2016 at 15:44
- @prakharsingh95 so Isn't there any other way around? I really need this. What do I need to know or learn? – Explosion Commented Nov 12, 2016 at 16:20
2 Answers
Reset to default 6alert()
is a global function, ie window.alert()
so can be overwritten.
Most likely, you'll still want the alert, so you can keep a record of it before overwriting, giving:
window.old_alert = window.alert;
window.alert = function(msg) {
// Process the msg here
console.log(msg);
// still show the original alert
old_alert(msg);
};
alert() function when executed is passed to the Browser to execute. Each browser executes it in its own way. So a way around is to override the alert() function itself.
Some javascript code on the page might be calling the alert() function. Maybe you can try to find the place in the code where it is called. The argument to alert() is what you need. You can override the default alert function using your own as described in: JavaScript: Overriding alert() . So you can do (as taken from the above answer):
(function(proxied) {
window.alert = function() {
// do something here
// arguments is what holds what you want.
return proxied.apply(this, arguments);
};
})(window.alert);
@freedomn-m's answer is more relevant and apt. But you can use the answer for overriding alert() for more examples on how to do it.