Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Setting innerHTML

Reply
Thread Tools

Setting innerHTML

 
 
Chris Moltisanti
Guest
Posts: n/a
 
      06-06-2006
Hey,

I have a DIV and I want to dynamically set its innerHTML. I know I can
set it by doing the following myDiv.innerHTML = '<img
src=\"myImage.gif\">'
However, the html that I want to set in it is quite large so I dont
want to have to hard code the HTML like I just did.
My question is....is it possible to assign an existing html page to the
innerHTML.
e.g. myDiv.innerHTML = 'mytest.html'
So that the contents of the mytest.html would be set in myDiv's
innerHTML.

Thanks,

Chris

 
Reply With Quote
 
 
 
 
Chris Moltisanti
Guest
Posts: n/a
 
      06-06-2006
Thanks for the reply.

I have use AJAX a little bit, bu I am unfamiliar with calling a pag
with AJAX. Any ideas on the syntax to do this?
I thought AJAX was more for making server calls.......

Chris.

 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      06-06-2006
Chris Moltisanti wrote on 06 jun 2006 in comp.lang.javascript:

> Thanks for the reply.


What reply?

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at the
top of the article, then click on the "Reply" at the bottom of the article
headers.

<http://www.safalra.com/special/googlegroupsreply/>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Chris Moltisanti
Guest
Posts: n/a
 
      06-06-2006
The previous post is not related to javascript so please ignore it.
My question again is how can I get an animated GIF to continue
animating while some javascript processing is bien executed.

Thanks

Chris

 
Reply With Quote
 
Chris Moltisanti
Guest
Posts: n/a
 
      06-06-2006
The previous post is an annoyance and unrelated to javascript. Please
ignore it.
My question again........how do I call a page using AJAX? Is AJAX not
ususally used for server calls?

Thanks

Chris

 
Reply With Quote
 
Ivo
Guest
Posts: n/a
 
      06-06-2006
"Chris Moltisanti" wrote
> The previous post is an annoyance and unrelated to javascript. Please
> ignore it.
> My question again........how do I call a page using AJAX? Is AJAX not
> ususally used for server calls?
>


What previous post? You didn't quote it, which is a very simple thing to do,
which is one of the reasons why quoting previous posts has become such a
common thing on Usenet. The other reason is of course that it is nothing but
sensible to quote what you are replying to. I 'd like to be able to judge
for myself whether or not it is related to javascript, not because I don't
trust your judgement, but just because I 'd like to help take the discussion
further. And how can I discuss what I haven't read?

As to the thoughts on AJAX: I believe if I make an AJAX call, it is by
definition to a server. If the URL used is (also) meant to be accessed
through a regular HTTP connection and viewed in a browser on its own, you
might indeed say I am calling "a page" using AJAX, but the word game has
little significance. Whatever the server responds with is either a string of
text (possibly containing HTML tags or other code) or an XML object to the
receiving javascript, and is to be treated as such within the original page.

hth
ivo
http://www.yorick.onlyfools.com/


 
Reply With Quote
 
Eric Ryan Harrison
Guest
Posts: n/a
 
      06-07-2006
Another more simplistic option would be to have your javascript merely
use document.createElement to create an iframe, set the iframes src to
whatever page you want the div to contain and then appendChild on the
div. Maybe not as clever or web2.0'ish enough for you, but it
definitely will get the job done in the least amount of code.

-E

andy baxter wrote:
> On Tue, 06 Jun 2006 14:27:59 -0700, Chris Moltisanti wrote:
>
> > Thanks for the reply.
> >
> > I have use AJAX a little bit, bu I am unfamiliar with calling a pag
> > with AJAX. Any ideas on the syntax to do this?
> > I thought AJAX was more for making server calls.......
> >

>
> I've just been doing something like this using dojo (www.dojotoolkit.org),
> which makes it pretty easy:
>
> function infoPage(url,callback) {
> // the url to load.
> this.url=url;
> // is the file loaded and parsed?
> this.ready= false;
> // did the loading fail?
> this.fail=false;
> // reference to a div with the page in it.
> this.infoNode=null;
> // callback for when the html has loaded.
> this.callback=callback;
> this.load= function() {
> // load the data file.
> var bindArgs = {
> url: this.url,
> mimetype: "text/html",
> error: dojo.lang.hitch(this,"loadError"),
> load: dojo.lang.hitch(this,"loaded")
> };
> var requestObj = dojo.io.bind(bindArgs);
> };
> this.loaded=function(type, data, evt){
> // handle successful response here
> // parse HTML into DOM nodes.
> var newNodes=dojo.html.createNodesFromText(data,true);
> this.infoNode=newNodes[0];
> // callback which does any further processing - e.g. inserting the node
> in the document.
> this.ready=true;
> this.callback(this);
> };
> this.loadError= function(type, errObj){
> // handle error here
> this.fail=true;
> alert("Failed to load page");
> }
> }
>
> If you don't like toolkits, you'll probably have to write your own
> javascript to parse html into DOM nodes, or else use innerHTML.


 
Reply With Quote
 
Eric Ryan Harrison
Guest
Posts: n/a
 
      06-09-2006

andy baxter wrote:
> On Wed, 07 Jun 2006 01:36:29 -0700, Eric Ryan Harrison wrote:
>
> > Another more simplistic option would be to have your javascript merely
> > use document.createElement to create an iframe, set the iframes src to
> > whatever page you want the div to contain and then appendChild on the
> > div. Maybe not as clever or web2.0'ish enough for you, but it
> > definitely will get the job done in the least amount of code.
> >
> > -E

>
> I tried this way first, but I didn't like the iframe - you have to set a
> fixed height window with a scrollbar and it looked ugly in my layout.


I don't know exactly what you're reffering to here. I've seen some
darned pretty Iframes. Iframes are CSS-ready, and if the page coming
back in the iframe has any sort of style, it'll be properly rendered as
well.

Good luck,

-E

 
Reply With Quote
 
Dr John Stockton
Guest
Posts: n/a
 
      06-09-2006
JRS: In article <>, dated Thu, 8 Jun
2006 11:07:03 remote, seen in news:comp.lang.javascript, Tony <tony23@ds
lextreme.WHATISTHIS.com> posted :
>Chris Moltisanti wrote:
>> The previous post is not related to javascript so please ignore it.

>
>Why are you telling me what to do?
>
>What post are you referring to?
>
>Please quote what you are replying to. If you don't want to play by the
>rules, then go play somewhere else.


He's a Google user, so don't assume intelligence; tell him to read the
newsgroup FAQ.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
 
Reply With Quote
 
lofty00@fastmail.fm
Guest
Posts: n/a
 
      06-09-2006

Eric Ryan Harrison wrote:

> andy baxter wrote:
> > I tried this way first, but I didn't like the iframe - you have to set a
> > fixed height window with a scrollbar and it looked ugly in my layout.

>
> I don't know exactly what you're reffering to here. I've seen some
> darned pretty Iframes. Iframes are CSS-ready, and if the page coming
> back in the iframe has any sort of style, it'll be properly rendered as
> well.
>
> Good luck,


As far as I know, an iframe has to have a fixed height and any overflow
is dealt with by putting a scrollbar in the window. I didn't want that
- I just wanted the html included in the page like any other html text.

andy baxter (lofty00 while I'm away)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xhtml, innerHtml, appendChild, and innerHTML. what is the exact proper way to do this with DOM sonic Javascript 5 07-11-2006 08:17 AM
BUG: Setting Server Control's InnerHtml forces Constructore to be called. =?Utf-8?B?am9obmRvZUBkcml2ZXIubmV0?= ASP .Net 10 02-24-2004 07:01 PM
Setting the innerHTML on a <span> Kerri ASP General 2 09-30-2003 05:31 PM
Setting the innerText / innerHTML on a <span> Kerri ASP General 4 09-28-2003 03:04 PM
Problem: Setting MSIE iframe innerHTML change relative href/src to absolute href/src Soren Vejrum Javascript 4 07-05-2003 01:47 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57