Welcome to WebmasterWorld Guest from 3.231.226.211

Forum Moderators: travelin cat

Message Too Old, No Replies

Javascript onclick not working in Safari

     
5:14 pm on Sep 27, 2006 (gmt 0)

New User

10+ Year Member

joined:Sept 27, 2006
posts:3
votes: 0


I have a page that lists users of the system for an administrator. There are icon links that are intended to perform certain actions on the specific user, but clicking the icon in Safari does nothing.

Here is the relevant script:

function deleteuser(strmail,userid)
{
strmsg = 'Are you sure you want to inactivate this user (' + strmail + ')?';
if(confirm(strmsg))
{
var objform = document.getElementById('adminusers');
var objcid = document.getElementById('usercid');
var objaction = document.getElementById('useraction');
objcid.value = userid;
objaction.value = 'Delete';
objform.submit();
}
return false;
}

And now the code for a link:

<a href="javascript:void(0)" onclick="return deleteuser('a@a.com',1)"><img border="0" src="mini_delete.gif" alt="Inactivate User"></a>

Any ideas?

Thanks
David

2:11 pm on Sept 29, 2006 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Dec 9, 2003
posts:3416
votes: 0


Welcome to WebmasterWorld, dgmagill!

I took your sample code and added the following bit of code (which I presume sufficiently mirrors your form HTML):

<form action="" method="get" id="adminusers">
<input type="hidden" name="usercid" id="usercid" value="" />
<input type="hidden" name="useraction" id="useraction" value="" />
</form>

I then ran this in Safari Version 2.0.4 (419.3) and it worked exactly as expected. What version are you experiencing the failure? Is there other javascript on the page that could be conflicting with this function?

1:28 pm on Oct 12, 2006 (gmt 0)

New User

10+ Year Member

joined:Sept 27, 2006
posts:3
votes: 0


I am running Safari Version 2.0.4 (419.3), but there are two differences in my code versus your test.

First, the form is submitted with "Post" to a page for the actual deleting of the user. Second, the input field name and id attributes are different. I will change the name to equal the id and re-test, but I must use "Post" for security reasons.

Thanks
David

4:23 pm on Oct 12, 2006 (gmt 0)

New User

10+ Year Member

joined:Sept 27, 2006
posts:3
votes: 0


Found the problem - there was another method in the script (totally unrelated to this form and not called at this time) that had a parsing error in it that IE and Firefox allowed to run without error. Safari complained and then would not allow any other method in the script to be invoked.

Thanks for your help,
David