Require a Page Init Javascript Function

Posted on 2006-06-05
Last Modified: 2008-03-17
I have a website built in NetSuite. I have also created an form in NetSuite for capturing new leads on the website. The form has a piece of code that runs when it initializes:

if ( isFocusable( document.forms['main_form'].elements['custentity_cust_5day'] ) ) { document.forms['main_form'].elements['custentity_cust_5day'].focus();document.forms['main_form'].elements['custentity_cust_5day'].select();}

Which causes the cursor to focus on the first field in the form. I have embedded this form in an I-Frame on my webpage and it caused the page to jump down to the first field in the form. To avoid this I had to plant some code in the i-frame to bring the focus back to the top of the page. You will notice that the page has a little blink in it,

Now, I am able to replace the delivered code above (if ( isFocusable( document.forms.....) with my own javacript which will run at initialization. I simply need a javascript function that does not force the focus to the first element in the custom form, but leaves the focus at the top of the page. Anyone? I am not a coder but this seems like a pretty quick little script.
Question by:tfoydel
    1 Comment
    LVL 49

    Accepted Solution

    You can try using the window.scrollTo function:
    <body onload="window.scrollTo(0,0);">


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
    In Part 1 ( we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now