Martin Atkins (mart) wrote in lj_dev,
Martin Atkins
mart
lj_dev

Mac OS X debugging needed

It's been reported that the S2 customize interface doesn't work properly in Safari. Specifically, clicking the Override checkboxes fails to switch between the server-supplied value and the entry checkbox as it does in other browsers. I don't have a Mac, so I was hoping a Mac user who knows a little (or a lot!) about JavaScript and DHTML could debug this. The easiest thing to check first of all is whether any JavaScript error is being thrown as a result of clicking the checkbox. However, there are also a number of ways the event handler for clicking could fail without an error, so if there is no error some more in-depth debugging will be necessary.

Some simple test code should help, I think:

<script language="JavaScript">
function test() {
    if (!document.getElementById) {
        alert('No document.getElementById!');
        return;
    }
    var odiv = document.getElementById('test:test');
    if (!odiv) {
        alert('Failed to grab test:test!');
        return;
    }
    var oclicky1 = document.getElementById('test:clicky1');
    if (!oclicky1) {
        alert('Failed to grab test:clicky1!');
        return;
    }
    var oclicky2 = document.getElementById('test:clicky2');
    if (!oclicky2) {
        alert('Failed to grab test:clicky2!');
        return;
    }
}
function clicky() {
    var oclicky1 = document.getElementById('test:clicky1');
    if (!oclicky1) {
        alert('Failed to grab test:clicky1!');
        return;
    }
    alert(oclicky1.checked ? 'Click On' : 'Click Off');
}
</script>
<body onload="test();">
<div id="test:test">Test</div>
<form method="POST" action="http://nowhere.invalid/">
<input type="checkbox" name="test:clicky1" id="test:clicky1" onchange="clicky()">
<input type="checkbox" id="test:clicky2">
</form>
</body>

This code should produce no messages onload in Safari. Sadly, it might be hampered by some onload alert blocking if Safari does that. I don't know enough about the browser to say. Hopefully someone can adapt this test code to actually test it if that is the case. By all means write your own test code if mine doesn't work!

Update: It looks like Konqueror doesn't support the “onchange” event but it does “onclick”. Can a Safari user confirm that this is the same in Safari? I think the fix is to just have both onclick and onchange events with the same code and let it just run one extra time in some browsers which support both, but we'll have to test and make sure it doesn't break any currently-working browsers.

Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 20 comments