0

I have a basic Javascript with a simple alert alert('Working...'); and I try to use on a list I have called "Users"

The result must be appears the alert "Working..." when I go to the list "Users" but no works

I did the same about the main page of the site and works

All I did was added the Javascript on the Site Assets

Added <script src="...JavascriptURL" type="text/javascript"></script> on Home.aspx on Page Assets

I went to the Home Page of my site and added a new web element and edited the code to <script src="...JavascriptURL" type="text/javascript"></script>

Working on Home Page, shows the alert

Now I'm trying the same on a list page display form but don't do nothing

I follow the steps on this video youtube.com/watch?v=Y9WHroEFO7g&t=71s

Where I can add the JS script? Any solution?

0

If you just wish to display the alert in the List -

  • Go to the list "Users"
  • Click on "Site Actions" --> "Edit Page"
  • Insert a new web element with your code <script src="...JavascriptURL" type="text/javascript"></script>

If you wish to display the alert in the Display Form, Edit Form or New form of the list (basically, show then in the new, edit and display modes) then -

  • Go to list "Users" --> "List Settings" --> "Advanced Settings" --> "Dialogs" --> "Launch forms in Dialogs" --> Change this to "No". This will open up all your list items in full-page mode and not in pop-up boxes. This will let you edit the new, edit and display forms
  • Follow the same step as above to add your javascript (edit page, add new web element)
  • Once done, Go to list "Users" --> "List Settings" --> "Advanced Settings" --> "Dialogs" --> "Launch forms in Dialogs" --> Change this back to "Yes"

Hope this helps!

  • I dit it but still not working in the List and in the Display Form, Edit Form or New form of the list too – Paolo Frigenti Apr 23 '18 at 12:00
  • Can you share what steps you followed. What is the web element that you're trying to add? Script editor or content editor? – Satyajit Paul Apr 23 '18 at 12:03
0

The quick solution: adding the "Script Editor" webpart on the page and referencing your javascript there.

But...You might also want to learn more about the "JSLink" which is then referenced in the webparts settings.

  • What is "Script Editor" and where is it? I have edited with a video I follow – Paolo Frigenti Apr 23 '18 at 11:04
  • Click on Edit Page>Add Web Part>Media and Content>Script Editor. – Tally Apr 23 '18 at 11:33
  • The console show me this error... Ha fallado la carga del <script> con origen ".../Lists/SiteAssets/js/lists/Demo.js". AllItems.aspx:448 El uso de eventos Mutation está desaprobado. Use en su lugar MutationObserver. mquery.debug.js:1039:24 unreachable code after return statement – Paolo Frigenti Apr 23 '18 at 11:58
  • Don't know spanish but looks like this is not a SharePoint problem but the problem with your Javascript code. – Ciamas Apr 23 '18 at 12:22
  • But on main page works and JS is the same – Paolo Frigenti Apr 23 '18 at 13:42

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.