简体   繁体   中英

How to scroll to top of window in NetSuite?

I want to use the following code to notify user while the page is initialized in NetSuite:

context.form.addPageInitMessage({
            type: message.Type.INFORMATION,
            message: 'Please check SO unit cost',
            duration: 5000
        });

And then automatically scroll to top of window to make the message be displayed in case user may miss the message if scroll down.

I'v tried some code to scroll the page to top of window but in vain. For example:

$(window).scrollTop(0);  
window.document.body.scrollTop=0;

What is the correct way to do it?

I guess you would like to scroll up to top of window using attached client script to record.

Then below code works in my environment.

jQuery(window).scrollTop(0); 

Like @Kenji suggested :

jQuery(window).scrollTop(0);

Will work : when you want to use JQuery in SuiteScript code, you need to use "JQuery" and not the alias "$".

Also, be careful, that you need to add this code in a Client Script and not in the Suitelet or the User Event script where you are displaying the message : you are here interacting with the browser so it must be a Client Script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM