1

I have a new modern news webpart in classic SP Online and I need to hide the "+ Add"

Could you explain how this can be done with JS? Iframe

Script

I have the following code, how can this be used to not load the "+ Add"

<script src="https://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function(){
        var f=$('#iframeID')
        f.load(function(){ 
            f.contents().find('.feedback_88fc6c94').hide(); 
        })
    })
</script>
3
  • Try adding this selector: document.querySelector("button[data-automation-id='newsAddButton'").style.display = "none" Commented Nov 1, 2018 at 12:47
  • Would the selector be in the script part of the script? or in the iframe? As i have place an id tag in the iframe and loading a separate JS script Commented Nov 1, 2018 at 13:13
  • <script src="code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ var f=$('#newsAddButton') f.load(function(){ f.contents().find('.feedback_88fc6c94').hide(); }) }) </script> Commented Nov 1, 2018 at 13:30

1 Answer 1

1

Customizing the modern sharepoint with custom JS/HTML/Whatever is totally against best practices (established by MS).

You have 2 options here if you want to stick to the best practices (im pretty sure you cant customize it anyway).

  1. Create a SPFX Webpart with the same functionality as the news webpart - https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part

  2. Create a SPFX Extension to customize that webpart (i dont think it works on customizing webparts, but i'm not sure) - https://docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/overview-extensions.

EDIT: You could also create a custom JS webpart (like the old content editor) or use a open sourced one. You can read more in this answer here -> SPFx Replacement for Script Editor Web Part

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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