question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Where to place client script

See original GitHub issue

When I navigate my pages, the page is not loading to the top of the new page.

  1. Is there some reason the new page wouldn’t navigate to the top as default?
  2. Where would I send JavaScript to the client? I tried putting a window.scrollTo(0, 50); in the Article’s componentDidMount, but that doesn’t work for obvious reasons. Must I use the Document setting of static.config.js, or is there a faster, cleaner way?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tannerlinsleycommented, Jan 16, 2018

To wrap this up for posterity, client scripts (like google analytics, fonts, or any other assets that are site wide or external) can be placed in your Document component in your static.config.js file. For inline scripts, you will need to dangerouslySetInnerHtml.

0reactions
ComputerCarlcommented, Jan 18, 2018

Being able to have window work in componentDidMount made me smile. 😃

    componentDidMount () {
        window.scrollTo(0,0);
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Client scripts - Product Documentation | ServiceNow
Client scripts allow the system to run JavaScript on the client (web browser) when client-based events occur, such as when a form loads, ......
Read more >
Client Side API - Scripting In ServiceNow - YouTube
Part-19 - ServiceNow provides client-side JavaScript APIs allowing all of you to control aspects of how ServiceNow is displayed and ...
Read more >
Client Script - An Overview | Online Help - Zoho CRM
Client script is a piece of JavaScript code that runs on your web browser instead of the server, thus returning an immediate response....
Read more >
Client-Server Model | Roblox Creator Documentation
Roblox executes code through client-side LocalScripts, server-side Scripts, and ModuleScripts which let you reuse code and share functionality. The following ...
Read more >
Create a GlideAjax call from a client script to a script include
Even as a ServiceNow dev with 5 years of experience I will find myself looking up GlideAjax syntax when I have to write...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found