SunQuest
           Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old November 26th, 2004, 11:20 PM
bsmith bsmith is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: palm bay, fl, usa
Posts: 204 bsmith User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to bsmith
JS - Load File --- Local Or Remote

I have been looking for a while, but I could never find a valid, pure JS example.

I have a file, on my server, say "updates.txt", that updates refrequently. (not really, just pretend).

I have been trying to code a Java Script to load that file via a form button, and output the contents to say a textarea, or even the InnerHTML of my DIV block.

Anyone know how?

Thanks!

Reply With Quote
  #2  
Old November 27th, 2004, 03:16 AM
bsmith bsmith is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: palm bay, fl, usa
Posts: 204 bsmith User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to bsmith
RE: JS - Load File --- Local Or Remote

Well, a few hours more of working/search for one. Here is 1 way of doing it. JS doesn't seem to have a reload "loadFile" that you can call.

Code:
<SCRIPT LANGUAGE="JavaScript">
  var nn4 = (document.layers);
  var nn6 = (document.getElementById && !document.all);
  var ie4 = (document.all && !document.getElementById);
  var ie5 = (document.all && document.getElementById);

  function loadPage(id,nestref,url) {
    if (nn4) {
      var lyr = (nestref)? eval('document.'+nestref+'.document.'+id) : document.layers[id]
      lyr.load(url,lyr.clip.width)
    }
    else if(ie4) parent.contentFRM.location = url;
    else if(ie5 || nn6) document.getElementById('contentFRM').src = url;
    setTimeout('showPage("contentLayer")',1000);
  }
  function showPage(id) {
    if (ie4) {
    document.all[id].innerHTML = parent.contentFRM.document.body.innerHTML;
    }
    else if(nn6 || ie5) {
      document.getElementById(id).innerHTML = window.frames['contentFRM'].document.body.innerText;                          
    }
  }  
</script>

</HEAD>

<BODY onload="parent.showPage('contentLayer')">

<a href="javascript:loadPage('contentLayer',null,'load-html-demo.html')">Load Page</a>
<iframe name="contentFRM" id="contentFRM" width="0" height="0" frameborder="0" src="load-html-demo.html">
</iframe>
<div id="contentLayer" style="position:absolute; width:345px; height:115px; z-index:1; left: 186px; top: 304px"></div>


Then create a file called "load-html-demo.html", and paste in what ever you want. I found it on http://javascriptsource.com .. Sightly modified some!

Reply With Quote
  #3  
Old November 30th, 2004, 10:35 PM
rehfeld_dot_us rehfeld_dot_us is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Posts: 825 rehfeld_dot_us User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: JS - Load File --- Local Or Remote

look at the xml HTTP Request Object in javascript


i wanted to do the same thing you wanted, and after searching around i found they have something suited exactly to this.

me personally, i thought it would be cool to have message boards use it. instead of re-downloading the entire html page to view the next page of posts, you could use js to swap the inner html w/ the new data, all in the background. it could even be preloaded, for near instant page to page views

Reply With Quote
  #4  
Old November 30th, 2004, 10:39 PM
rehfeld_dot_us rehfeld_dot_us is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Posts: 825 rehfeld_dot_us User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: JS - Load File --- Local Or Remote

heres a demo

http://developer.apple.com/internet/webcontent/XMLHttpRequestExample/example.html

Reply With Quote
  #5  
Old December 1st, 2004, 08:30 PM
bsmith bsmith is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: palm bay, fl, usa
Posts: 204 bsmith User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to bsmith
RE: JS - Load File --- Local Or Remote

Thanks for that link. It is what I was looking for, now the fun part of trying to remember why I had wanted to do that!


Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > JS - Load File --- Local Or Remote


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway