1 members and 66 guests
Most users ever online was 695, 02-16-2011 at 07:01 AM.
» Site Navigation
» Domains For Sale
|
-
Easy way to update a DIV?
I've been out of HTML coding for a while and now trying to get back up to speed. I used to use frames to organize the content on my web page. Frames are nice since you can easily swap out a file to display by using the src attribute.
I'm trying to get away from using frames, but haven't found a good replacement for the frame. Is there any way with a DIV or CSS to update the contents of a document or DIV with another file?
I've been using javascript to dynamically update my DIV, but there must be an easier way.
BTW, my web page is now organized so one DIV holds my navigation menu, and the other div is for displaying what I select from the menu.
Thanks for your help!
[Tim]
-
Keep in mind the original rule: all tagnames are simply MARKUP. They inform the recipient device how to format the content for display.
iFrames are intended to display documents from other servers, hence the src attribute.
divs are intended to represent block elements, whose content originates on the local server. AJAX extends possibilities by enabling scripts to retrieve data from a server at runtime and display the new data within the document's markup as well. Generally speaking, a document cannot be piped into a div when it originates from another server, and browsers have built-in safeguards against it so as to secure data from cross-site attacks. If you want to include data from a remote server on your page within a div via AJAX then your own server needs to make the call to the remote host and then return the data to the client.
That said, you probably already know that you may replace the content of a div in javascript with:
document.getElementById(divId...).innerHTML = "<span>my new Content</span>";
jQuery makes all this much easier. See jQuery.org for samples and walkthroughs....
We're BACK !!! 
-
Great information dear, I like it very much.
-
Hi,
And much like the gmail app I want only the inner div to be updated .... you're using, I tried to provide you a clean/easy way to update a div.
I tried using ... Update: The <div> that I want centered is one of three <div> s in one <div> .
Wondering if there is some reason why there is no "easy" way to center something on a page, or even center a div vertically, an even greater challenge.
-
Great information dear, I like it very much.
-
Updating the content of div with javascript
<script type="text/javascript">
function ReplaceContentInContainer(id,content) {
var container = document.getElementById(id);
container.innerHTML = content;
}
</script>
<div id="example1div" style="border-style:solid; padding:10px; text-align:center;">
I will be replaced when you click.
</div>
<a href="javascript:ReplaceContentInContainer('exampl e1div', '<img src='2.jpg'>' )">
Click me to replace the content in the container.
</a>
Hire the best Professional Website designer for your next project
Affordable and Professional Website Designer with expertise in Joomla Development. Hire the best professional for your online business.
Similar Threads
-
Replies: 8
Last Post: 11-07-2009, 02:58 PM
-
By sirtech in forum HTML / XHTML / XML
Replies: 1
Last Post: 01-14-2006, 12:27 AM
-
By Arrekusuof93 in forum Javascript / AJAX / VBScript
Replies: 1
Last Post: 08-12-2005, 06:41 PM
-
By htmlhelp in forum Chat Central
Replies: 6
Last Post: 12-14-2004, 03:02 AM
-
By serafina in forum HTML / XHTML / XML
Replies: 1
Last Post: 07-31-2002, 09:21 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|