homepage Welcome to WebmasterWorld Guest from 54.145.172.149
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Can javascript call a .html or .txt file without i-frames?
Simone100

5+ Year Member



 
Msg#: 3155951 posted 7:52 am on Nov 14, 2006 (gmt 0)

Hello, is is possible to call a certain file type with javascript without using i-frames? Please let me know, thank you very much. Simone

 

ericfwebmaster

10+ Year Member



 
Msg#: 3155951 posted 6:29 pm on Nov 14, 2006 (gmt 0)

you can call a .js file with the [script type="text/javascript"]
document.write("Hello World!")
[/script]

and add the html in where Hello World! is.

Little_G

5+ Year Member



 
Msg#: 3155951 posted 6:57 pm on Nov 14, 2006 (gmt 0)

Hi,

Take a look at AJAX [developer.mozilla.org]

Andrew

Simone100

5+ Year Member



 
Msg#: 3155951 posted 7:17 pm on Nov 14, 2006 (gmt 0)

Eric I think that is what I need. Any idea how to put .html there?
Thanks.

kaled

WebmasterWorld Senior Member kaled us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3155951 posted 7:38 pm on Nov 14, 2006 (gmt 0)

It sounds like you want to display an html file in a div (or something along these lines). Whilst there are ways this can be done you should probably look at server-side includes first. In any case, without more details about what you want to achieve and why, no one will be able to give you reliable advice.

Kaled.

Simone100

5+ Year Member



 
Msg#: 3155951 posted 8:55 pm on Nov 14, 2006 (gmt 0)

Thanks. I need to know if there is a way to call a html page using javascript. Not an href link but an actual html page somewhere without an iframe. If javascript doesn't have these features please tell me, because I have looked everywhere online and can't find any information about this.

If javascript will not do this, is there a way I could put a server side include into an array and have javascript insert the server sides into my page? The reason I don't stick the server side directly into the page is because I want to rotate it. Please let me know, thank you very much!

kaled

WebmasterWorld Senior Member kaled us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3155951 posted 10:59 pm on Nov 14, 2006 (gmt 0)

Again, more detail required. For instance, if this is going to be place at the bottom of the page and the size is known roughly, you could use an <iframe> without problems (other than an extended blank area at the bootom of the page).

Another way would be to use a hidden <iframe> and write an onload event handler to copy the contents into a <div>. It would work something like this, but I haven't tested the code below.

<iframe name="fudge" onload="copyTo(this,'divId')" height="0" src="default.html">

function loadHtml(url){
// fudge.location.replace(url);
// fudge.location.href = url;
fudge.src = url;
}

function copyTo(iframe,divId){
var div = document.getElementById(divId);
if (div) div.innerHTML = iframe.document.body.innerHTML;
}

When testing, set the iframe height to something like 100

Kaled.

Simone100

5+ Year Member



 
Msg#: 3155951 posted 1:50 am on Nov 15, 2006 (gmt 0)

Could I do that using a server side instead of an Iframe? Iframes take so long to load.

kaled

WebmasterWorld Senior Member kaled us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3155951 posted 2:49 am on Nov 15, 2006 (gmt 0)

Iframes are no slower than images to load (the mechanism and overheads are identical).

You could use ajax technology, however, this requires scripts to be run on the client (javascript) and the server (typically perl I think).

Again, without more detail as to what you want to do and why, no one can give you reliable advice. So far, you haven't even said whether you are using static html or php (or something else).

Kaled.

daveVk

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3155951 posted 4:29 am on Nov 15, 2006 (gmt 0)

What is the reason for not wishing to use iframes? You dont wont a solution that has the same problem.

Simone100

5+ Year Member



 
Msg#: 3155951 posted 6:30 am on Nov 15, 2006 (gmt 0)

Thanks everybody, maybe some of you can tell me if javascript can rotate .html or .txt files. Kaled, I have been pretty detailed. I said I wanted to know if you can call a file using javascript. An html file or a .txt file. I don't know what is confusing.

Php can call these type files, was wondering if javascript could do the same.

I notice on a couple of exact same rotators I have, replacing it to rotate iframes instead of images, that the iframes rotate at a couple seconds minimum, for a tiny html file or tiny .txt file. Compared to rotating the images which can go very, very, fast in milliseconds even. That is why I wanted to find out other options other than Iframes to see if I could rotate some items faster. Please let me know, thanks.

daveVk

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3155951 posted 7:10 am on Nov 15, 2006 (gmt 0)

I take it your main concern is speed? With images this is probably achieved by loading them all from server on initial load (slowing initial page load somewhat), then rotation does not involve going to server at all (very fast). A similar approach could be taken with text/html, but the delay on loading them all on initial page load may be excessive depending on how many and how big you are talking about.

Simone100

5+ Year Member



 
Msg#: 3155951 posted 10:53 pm on Nov 15, 2006 (gmt 0)

Hi there Dave just realized that was you, will continue to keep checking on the bank situation.

Sounds like you might be saying iframes might be slower when they are loading whole files because they have to go to the server and browser where images are only in our ftp account? Don't know if I read you right on that or not. No one has told me whether javascript can call .html or .txt files, (actual files not text), guess that means they can't.

Leosghost

WebmasterWorld Senior Member leosghost us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3155951 posted 11:50 pm on Nov 15, 2006 (gmt 0)

jscript can call pretty much whatever file type you want ..if you know how ;)..preloading in the background saves time ....and jscript calls are usually faster than php ..when the result is rendered on the browser..howver this also depends on the config of the veiwing machine and the other things it is doing ..be they background or not

BTW ..and politeness when asking questions which were not expressed as detailed as you may have thought will get you much more ( free ) help ..or you might try fora where you can be cavalier with the respondants ..but they usually require that you pay to see the answers ..or to get the knowledge that you dont have ..kaled was trying to help ..and needed clarification to do so

daveVk

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3155951 posted 4:41 am on Nov 16, 2006 (gmt 0)

As far as I am aware, loading via an iframe should not be slower than loading any other way. Try loading these files directly, that is type url into browser, is it still slow?

Simone100

5+ Year Member



 
Msg#: 3155951 posted 7:54 am on Nov 16, 2006 (gmt 0)

I'll test it that way sometime in the next week. Thanks.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved