Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8261473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:25:17+00:00 2026-06-08T03:25:17+00:00

I have a Browser and I am adding content to it in a way

  • 0

I have a Browser and I am adding content to it in a way similar to this:

browser.setText(browser.getText() + newText());

Then, when there is too more html than can fit inside the view, I want the browser to scroll down, so after each call to setText() I also do this (as suggested by answers to this question elsewhere on the web):

browser.execute("window.scrollTo(0, document.body.scrollHeight)");

However, this does not work! I’ve also tried using an anchor to scroll to, but that does not work either.

How can this be accomplished? Rather, where is the problem in my approach (which seems to have worked for others)?

Thanks

EDIT: Here’s my actual code:

protected void createContents() {
    shell = new Shell();
    shell.setSize(450, 300);
    shell.setText("SWT Application");

    final Browser browser = new Browser(shell, SWT.NONE);
    browser.setBounds(10, 10, 430, 220);

    Button btnNewButton = new Button(shell, SWT.NONE);
    btnNewButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseUp(MouseEvent e) {
            browser.setText(browser.getText() + "<p>weeee!!!</p>");
            browser.execute("window.scrollTo(0, document.body.scrollHeight)");
        }
    });
    btnNewButton.setBounds(10, 236, 430, 32);
    btnNewButton.setText("New Button");

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:25:20+00:00Added an answer on June 8, 2026 at 3:25 am

    Well I’ve figured out a way to do this. It’s very similar to my above approach, only instead of

    browser.setText(browser.getText() + "<p>weee!!</p>");
    

    I used

    String stringToAdd = "wee";
    browser.execute(String.format("document.write('%s')", stringToAdd
                    .replace("\\", "\\\\")
                    .replace("'", "\\'")
                    .replace("\"", "\\\"")));
    

    Still not sure what the problem with my initial approach was though…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have often used, and seen recommended, dom-access structures like this for adding content
I have created a web browser in c# this was what i get when
I have a simple file browser and there I display files and folders, obtained
Is there a way to add custom fields to the built in browser context
I know this is a bit contradicting seeing as the browser would have to
I have a div that has scrollable content, but it is vital that this
I have an Ajax site where I have browser navigation hooked up to ajax
With the new Silverlight 5, we can now have an In-Browser elevated-trust application. However,
Using browser firefox and chrome I have an input file element. <input type='file' id='tempFileInput'
I have a simple web browser embedded in an application that allows a user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.