Solved

How to change content of HTML DOM elements on jsp page from external javascript file ?

Posted on 2015-02-21
2
594 Views
Last Modified: 2015-02-21
I have this jsp

<html>
<head>
<script type="text/javascript" src="abc.js"></script>
</head>
<body>
<div id=container></div>
</body>
</html>

Open in new window



contents of abc.js
document.getElementById("container").innerHTML="Some TEXt";

Open in new window


I want to set some text in <div> from external javascript file.
What mistake I am doing ?
0
Comment
Question by:Pradip Shenolkar
2 Comments
 
LVL 10

Accepted Solution

by:
Jeffrey Dake earned 500 total points
ID: 40623874
Your script is included at the top of your file and firing right away. At that point the container div is not rendered. You could move your JavaScript file farther down in the Dom, or change it to be wrapped in a window on load event and have your script fired on that event.
0
 

Author Closing Comment

by:Pradip Shenolkar
ID: 40623879
Thank you
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Detect which div element is visible? ***Javascript Only solution*** 4 21
jQuery on Submit 4 42
Html Newline 7 21
Non-Resizable Pharagraph 2 7
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…
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…

828 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