Helpful Information
 
 
Category: JS
JS -> MAC -> Failing to forward

Hi All,
Quick problem with my JavaScript. Users on IE on MacOSX don't get any errors or any action being performed.

The Javascript:


<script>
function confirmSubmission(confirm_text,redirect_to) {
if (confirm(confirm_text)) {
location.href=redirect_to;
} else {
return false;
}
}
</script>


The Call:


<a href="#" onClick="confirmSubmission('Are you sure you want to change the status of the news item A NEWS ITEM?','/admin/news.html?action=processStatus&id=15');"><img src="on.gif" border="0" valign="absmiddle"></a>


Any tips/fixes/comments would be appreciated :wink:

Cheers,
g-a-t-e

isn't it easier than that?

this is how i do it...

<a href="http://www.yahoo.com" onClick="javascript: return confirm('Are you sure you want to\nproceed with this operation?');">This</a>

this works on everything for me...

good luck...v

Hi,
Don't have a MAC so I can't really tell you what is wrong, but I would firstly, make sure the script is in the <head> of your document. Second, define what type of script it is and thirdly, make sure you define the doc type. Here is your code doctored to XHML transitional DTD -> try ti to see if it works:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
<!--
function confirmSubmission(confirm_text,redirect_to) {
if (confirm(confirm_text)) {
location.href=redirect_to;
} else {
return false;
}
}
// -->
</script>
<title>Test</title>
</head>
<body>
<a href="#" onClick="confirmSubmission('Are you sure you want to change the status of the news item A NEWS ITEM?',
'/admin/news.html?action=processStatus&id=15');">
<img src="on.gif" style="border:0px;" /></a>
</body>
</html> Hope that helps, though it probably won't :mad:

EDIT: The above solution (vaaaska's) is definately the better way :)
That is the way I normally do it

I just decided to go the vaaaska way.. Not ideal but its only defined within a single class anyway.
All my doc types were correct, and the script in the right location. Haven't really got time to fiddle with it any further.

Cheers!