Topic: loading div with javascript? Pages that link to <a href="https://ozoneasylum.com/backlink?for=30924" title="Pages that link to Topic: loading div with javascript?" rel="nofollow" >Topic: loading div with javascript?\

 
Author Thread
nakins
Nervous Wreck (II) Inmate

From:
Insane since: Mar 2006

IP logged posted posted 03-20-2009 19:02 Edit Quote

Hi,
I'm trying to create the functionality of an iFrame with a div. What I need to do is load / reload a div with a partial html file (no <html> or <body> tags) . The html file always has the same name, it just might change or be added to during a 24 hour period. I understand that I can do something like window.GetElementById(some-Div). innerHTML = "blah blah blah", but what I would like to do (upon initial load) is something like Window.GetElementById(some-div).src = "http://mysite.com/myfile", then, find someway to reload the div when needed.

The reload would occur when a server side script runs that is called from an iframe, and the script writes some javascript code back to the page like parent.window.GetElementById(some-div).reload. BTW, I wanted to use a Div, instead of an iFrame, because the div would expand vertically.

Does this have the slightest chance of working? Any suggestions?

yossiadmon
Obsessive-Compulsive (I) Inmate

From: Israel
Insane since: Sep 2009

IP logged posted posted 09-07-2009 10:02 Edit Quote

You can do it using prototype library (http://www.prototypejs.org/assets/2008/9/29/prototype-1.6.0.3.js)
The following example will replace the content of specifc div (by id) with the content that will return from the url in the second parameter

code:
new Ajax.Updater('some div id', 'relative url to the page')

reisio
Paranoid (IV) Inmate

From: Florida
Insane since: Mar 2005

IP logged posted posted 09-07-2009 18:59 Edit Quote

Something lighter and more task-specific here: http://rick.measham.id.au/200606/jif-its-the-new-ajax/

coach
Nervous Wreck (II) Inmate

From:
Insane since: May 2011

IP logged posted posted 05-31-2011 11:07 Edit Quote
Edit TP: spam removed


Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu