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 6320053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:54:19+00:00 2026-05-24T15:54:19+00:00

I want to include Javascript code in a HTMLPanel element, but it is not

  • 0

I want to include Javascript code in a HTMLPanel element, but it is not working. Could you please help me? Thanks in advance.

Scripts/pro.js

alert('hello');

WITH HTMLPANEL DOES NOT WORK (no alert is displayed)

MyPage.java (which is EntryPoint for MyPage.html)

String preHtml="<script type=\"text/javascript\" src=\"Scripts/pro.js\"></script>";
HTMLPanel prePanel=new HTMLPanel(preHtml);
RootPanel.get("scriptContainer").add(prePanel);

MyPage.html

<td align="left" valign="top" id="scriptContainer"></td>

WITHOUT HTMLPANEL DOES WORK (alert is displayed)

MyPage.html

<td align="left" valign="top"><script type="text/javascript" src="Scripts/pro.js"></script></td>
  • 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-05-24T15:54:20+00:00Added an answer on May 24, 2026 at 3:54 pm

    I think it should be other way around. The HTMLPanel quoting the javadocs

    A panel that contains HTML, and which can attach child widgets to identified
    elements within that HTML.

    should wrap your container not your script. The below example works unless you absolutely have a reason to use HTMLPanel to wrap a script.

    HTMLPanel html = new HTMLPanel("<table><tr><td id='scriptContainer'></td></tr></table>");
    RootPanel.get().add(html);  
    Element script = DOM.createElement("script");
    DOM.setElementAttribute(script,"language","JavaScript");
    DOM.setElementAttribute(script,"src","Scripts/pro.js");
    DOM.appendChild(DOM.getElementById("scriptContainer"),script);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would I achieve the pseudo-code below in JavaScript? I want to include the
I want to pre-escape part of my javascript code and then include it in
I want to include validates_confirmation_of :password in a module but i keep getting errors
Ok, so I'm not having trouble with this per say, but I want to
hey there i want to change some css attributes from javascript but i cant
the code below is a jquery POST request javascript. i want to use the
Possible Duplicate: How to include a JavaScript file in another JavaScript file? I want
I want to include jquery.js in myjs.js file. I wrote the code below for
How do you include Javascript from a CDN source using Smarty? We have code
I am calling this in my code behind: (test.aspx) Response.Redirect(~/Default.aspx); I want to include

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.