XSL not rendering/acting properly in Chrome

2019-09-16 02:21发布

问题:

So, I'm working on updating 10-12 year old code to be Chrome compatable, and I've stalled out already. For whatever reason, when I input a number and then click the "fillPO" button, it doesn't update anything, and instead places a "null" into the box it should be filling. This works as intended on Internet Explorer. Is there a general rule to get this to work on chrome?

<xsl:template name="control-row">
    <xsl:if test="$orderApprove='true' and $isSuperUser='false' and $archiveView='false' ">
        <td nowrap="true" colspan="10">
            <input type="button" name="servlet" value="Approve" onClick="return approveOrder();">&nbsp;checked orders</input>
            <xsl:if test="/poursxml/OrderedFields/Field='PO'">
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                Fill PO number across orders:&nbsp;
                <input type="text" name="genericPO" id = "genericPO" size="15" maxlength="30"/>
                &nbsp;
                <input type="button" value=" Fill PO " onclick="fillPO()"/>
            </xsl:if>
        </td>
    </xsl:if>
</xsl:template>

This is the fillPO() in javascript.

function fillPO()
{
    if(!anySelected())
        alert('Please select an order first.');
    else
    {
        dfa = document.getElementsByName('orderNumber');
        len = dfa.length;
        var ix = 0;
        for(ix=0; ix<len; ix++)
        {
            if(dfa[ix].name == 'orderNumber')
            {
                if(dfa[ix].checked == true)
                {
                    el_id = dfa[ix].id;
                    position = el_id.substring(11);
                    document.getElementById('PONumber' + position).innerHTML = '<input size="15" maxlength="30" type="text" name="PONumber" value="' + document.getElementById('genericPO').getAttribute('value') + '"></input>';
                }
            }
        }    
    }
} 

回答1:

Wild guess: replace document.getElementById('genericPO').getAttribute('value') with document.getElementById('genericPO').value.

But we really need to see a sample allowing us to reproduce the problem in Chrome.



回答2:

Because there is no obvious problem (at least for me) in your posted code fragments. Here some Debug hints (which may help a little bit):

  • Consider to have a look to the generated html (perhaps copy and format it) and compare it against the IE generated html. This could be done in the Elements tab of chrome debugger.
  • Try to set an breakpoint in the possible not working javascript function.
  • If this still does not help. Consider to copy the probably server-sided generated xml. This could be done within the "Network" tab in chrome debugger. Try to reduces the xml and test it offline to find the trouble causing part.
  • If debugging doses not work as expected. Add some console.log("test point");or alert() calls to the javascript.

(.. may be continued ..)