views:

524

answers:

3

Dear all, I am using JQuery and Aajax, My Ajax.php file has returns the following field into Main File. While I am Click In Mozilla And Chrome , It Working Fine Gives alert, But when I use IE 7 Version 7.0.5730.13 ,It Didnt Supported , Does i Need to do anything on browser side or i have to modify Will u please Help Me in this context.

here my ajax.php has

echo " <a href='#' onclick=\"javascript:alert('hello')\ "> link</a>";

It return to main .html ,there i got didn't get alert in iE7

+2  A: 

You might want to get rid of the extra space after the closing parenthesis (this may just be a typo in your post, though), put in a semi-colon, and return false so that it doesn't attempt to follow the link.

echo " <a href='#' onclick=\"javascript:alert('hello'); return false;\"> link</a>";
tvanfosson
I have done the above code , I am surprise how its working in mozilla and chrome and not work iE7 may i know its reason?
venkatachalam
Just guessing, but I can think of a couple of ways this might happen. Moz/Chrome may not flush the event queue when the link is to the same page and thus the alert event happens despite the link being followed or Moz/Chrome may handle the alert before following the link whereas IE doesn't.
tvanfosson
Adding return false causes the link processing to be aborted so that following the link doesn't flush the pending javascript operations.
tvanfosson
Thanks However I still in the process of searching and modifying the code
venkatachalam
+1  A: 

could it be the space between the / and the " ?

John Boker
Is there any Equivalent syntax for ? echo " <a href='#' onclick=\"javascript:alert('hello'); return false;\"> link</a>";
venkatachalam
+1  A: 

You also don't need label "javascript" in your onClick event.

You can read more about it here: http://stackoverflow.com/questions/3761167/proper-way-of-calling-a-javascript-method

cps7