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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mimic the Alert Function...

Status
Not open for further replies.

MikeDamone

Programmer
Oct 21, 2003
106
US
Does anyone know how I can trick the browser into thinking an alert was issued and that the user clicked ok? Thanks
 
No. But if you tell us in what condition you want that to happen, maybe we can do something else.
 
Does anyone know how I can trick the browser into thinking an alert was issued and that the user clicked ok? Thanks

Why don't you tell us WHY you want this? What you've asked for makes no sense with some contextual information. Let me explain. Take the following code:

Code:
// some code
alert(1);
// some more code

As far as JS is concerned, the "some more code" will run when OK is pressed on the alert box.

If you want to simulate the "Ok" being clicked automatically, simply remove the alert altogether:

Code:
// some code
// some more code

As you can see, with the code above, not having the alert at all is the same as having an alert, and having "OK" clicked.

So... you'll need to tell us WHY you want to do this, or give us more information about the code surrounding your alert.

Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Ok thanks everyone. Here's my problem.

We have a software package from a vendor that is asp based. Inside this package, we write custom applications. This particular one is a .Net application, so when the vedor application loads, it also loads to IFrames and inside the IFrames is .Net code running from a separate server.

The 2 IFrames both use a little bit of Javascript. I know very little about javascript. The application loads fine, but when certain links are clicked and then the application re-loaded, I get the 'Permission denied' error. Now, I know its broswer security not letting javascript cross servers, however the 2 IFrames run code from the same server with the same domain.

The reason I asked about the alert behavior is bc in trying to debug it, I noticed that having an alert causes the error not to occur.

Any Ideas? Thanks
 
>>The reason I asked about the alert behavior is bc in >>trying to debug it, I noticed that having an alert >>causes the error not to occur.

Instead of Alert, try to wait for a few seconds see if it will work for you.

setTimeout(1800); //delay 1800 milliseconds
 
Sorry, I don't remember how to use setTimeOut.
 
Ah, I found something:

Code:
alert("hey");

//this will wait for 2000 milliseconds  before calling the next alert				
date = new Date();
var curDate = null;
do { var curDate = new Date(); } 
while(curDate-date < 2000);

alert("hello");
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top