Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
195
rated 0 times [  199] [ 4]  / answers: 1 / hits: 22716  / 11 Years ago, wed, june 26, 2013, 12:00:00

We have a control that was made by a company that no longer exists.
For some odd reason on page load it has now started rendering something like this to the page:



<script type=text/javascript>
alert('Your license has expired!')
</script>


Since the company no longer exists we can't get support and the control is also very complex and is running in some legacy code that can't be quickly replaced so simply rewriting the page is also not an option (yet).



What I need to do for the time being is to have the dialog either be removed from the page before it renders or auto closed by some script ...



Any ideas?


More From » alert

 Answers
42

You can not close an alert box, just you can hijack window.alert



window._alert = window.alert;
window.alert = function () {
};


The code would have to appear before the third party library's code. What this means is, if you want to use an alert, you would have to change your code.



One way would to call the method that has the reference



window._alert(hi);


Other way would be to overload the new function



window._alert = window.alert;
window.alert = function (msg, showItNow) {
if (showItNow) {
window._alert(msg);
}
};
window.alert(BOOOO!); //I will not show up
window.alert(hi, true); //I will show up

[#77392] Tuesday, June 25, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
myrap

Total Points: 407
Total Questions: 105
Total Answers: 109

Location: Cambodia
Member since Thu, Oct 7, 2021
3 Years ago
myrap questions
Tue, Feb 8, 22, 00:00, 2 Years ago
Wed, Jan 15, 20, 00:00, 4 Years ago
Thu, Oct 24, 19, 00:00, 5 Years ago
Thu, Oct 3, 19, 00:00, 5 Years ago
Mon, Aug 12, 19, 00:00, 5 Years ago
;