1

I have a page with Script Editor. now I need to add another one to try something without running the code at the first Script Editor.

Is there a method to disable the first Script Editor on my page without delete it or comment the code within it ?

1
  • 2
    The answer is No. It is like asking: I have two lines in my code, how can I run line 2 and not run line 1. Now SP does make it possible to exclude a line with Target Audience setting in the webpart properties.. but that requires different logins. Alternative you could change line 1 (script 1) to not run when there is a QueryParameter Sep 8 '16 at 22:52
0

Have you tried to add a document "script" Element after some logic?

var myscript = document.createElement('script');    
myscript.setAttribute('src','http://yoursite/myscript.js');    
document.head.appendChild(myscript);    
4
  • Thanks for your reply , but Should you tell me what this will do ? Sep 6 '16 at 20:14
  • That code creates a DOM script element in runtime. I've used it in some script editor (and content editor) to select which code to add programmatically. check more at: w3schools.com/jsref/dom_obj_script.asp Sep 6 '16 at 20:25
  • I really appreciated your answer , but what I need is to disable script at first script editor web part to run a second script at another script editor at the same page that is not related to the first one , so please tell me how I can use the above code to achieve this scenario , thanks in advance Sep 6 '16 at 20:56
  • ok, I'll take the time later to try to give you an example. Sep 6 '16 at 21:22

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.