Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

alert overwrite recall super

Status
Not open for further replies.

shekinskiy

Programmer
Nov 14, 2005
11
TR
i want overwrite alert, do somethink and recall super alert.

not problem at overwriting, but a cann't recall super alert.

Code:
function alert(aaa) {
    // do something
    confirm(aaa); // just for test, but works.
    //alert(aaa); //does not work, gives memory exception, it is understandable becaouse of recursive calling, but what is runnable way of coding.
}

thanks for any help.
 
Need an exit provision, in any case, one way or the other.
[tt]
function alert(aaa) {
// do something
var b=confirm(aaa); // just for test, but works.
//alert(aaa); //does not work, gives memory exception, it is understandable becaouse of recursive calling, but what is runnable way of coding.
if (r) {
setTimeout("alert('"+r+"')",50);
}
}
[/tt]
 
Amendment
The corresponding line should be read reflecting a change of mind.
[tt] var [red]r[/red]=confirm(aaa); // just for test, but works.
[/tt]
 
thanks tsuji,

2nd statement is only for testing that: overwriting works or not?.

i want to run code like bellow. i want to show alert dialog on screen at 3th statement, but 3th statment in code bellow cause recursive calling.

Code:
function alert(aaa) {
	var newDiv = document.createElement(newDiv);
    newDiv.innerHTML = aaa;
    setTimeout("alert('" + newDiv.innerHTML + "')", 50);
}
 
Do you mean you are satisfied with your new function? or that you don't know how to implement, in that case, what I said?
>(self) Need an exit provision, in any case, one way or the other.

Here is one way of how to do it, if you don't get it.
[tt]
var brecur=false; //global
function alert(aaa) {
if (!brecur) {
[green]//but what is this statement? you have newDiv global? somewhere?[/green]
var [red]newDiv[/red] = document.createElement([red]newDiv[/red]);
newDiv.innerHTML = aaa;
brecur=true;
setTimeout("alert('" + newDiv.innerHTML + "')", 50);
} else {
brecur=false;
}
}
[/tt]
But then, you use console display standard alert to do a task of non-console assignment job. That scores you not much points and confuse yourself and others no end.
 
i don't know how to implement.

i have a number of alert in my project. i need to overwrite alert for a reason. before exploring alert box, i need to do something. don't care about newDiv.

i have written a function named alert. alert statement in alert function should not call self, it should show box. i can't explore alert box on screen, i don't know how to implement to explore alert box on screen

Code:
function alert(aaa) {
    //do something
    //how to implement to show alert box? super.alert(aaa)?
}
 
Try this:
Code:
<script>
// Save the old alert.
var oldAlert = window.alert;

// Override with new alert.
window.alert = function(msg){

  // Do some stuff
  window.status = 'This is my alert function.'

  // Call the original alert function.
  oldAlert(msg);
}

// Test it
alert('Hi');
</script>

Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top