Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1093
  • Last Modified:

Require a Page Init Javascript Function

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, http://www.sightlinesconsulting.com.

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.
0
tfoydel
Asked:
tfoydel
1 Solution
 
RoonaanCommented:
You can try using the window.scrollTo function:
<body onload="window.scrollTo(0,0);">

-r-
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now