In custom NewForm.aspx or EditForm.aspx, the ribbon is hidden and the following is added:

<div class="row">
<div class="colFull" id="attachmentsOnClient">
    <span dir="ltr">
        <input type="file" name="fileupload0"  id="onetidIOFile" class="ms-fileinput" size="56" title="Name"></input>
    <div id="ieAttachBtn">
        <input name="Button1" type="button" value="Attach" onclick='OkAttach()' style="width: 6em; height: 1.7em" />
        <span id="idSpace"></span>
        <tr id="idAttachmentsRow">
            <td nowrap="true" valign="top" class="ms-formlabel" width="20%">
                <SharePoint:FieldLabel ControlMode="Edit" FieldName="Attachments" runat="server"/>
            <td valign="top" class="ms-formbody" width="80%">
                <SharePoint:FormField runat="server" id="AttachmentsField" ControlMode="Edit" FieldName="Attachments" __designer:bind="{ddwrt:DataBind('u','AttachmentsField','Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Attachments')}"/>
                    var elm = document.getElementById(&quot;idAttachmentsTable&quot;);
                    if (elm == null || elm.rows.length == 0)

ieAttachBtn is only needed in IE. It works without it in Chrome and Edge. Is there a way to show/hide this <div> based on browser?

I inserted the following code after PlaceHolderAdditionalPageHead, the alert works but the .getElementById().style.display does not.

<script type="text/javascript">
  if (/*@cc_on!@*/false) {
    alert('This is IE');
    document.getElementById("ieAttachBtn").style.display = "block";
  } else {
    alert('This is not IE');
    document.getElementById("ieAttachBtn").style.display = "none";

I solved this using the code below.

<script language="javascript">
function hideIEBtn() {
    if ($.browser.msie) {
    } else {
$(document).ready(function() {

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.