Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Any creative way to pull html content same way js files are pulled
- From: dlovering at gazos.com (David T. Lovering)
- Subject: [Javascript] Any creative way to pull html content same way js files are pulled
- Date: Mon Mar 31 07:54:56 2003
Well, there are a couple of apples mixed in with the oranges here... One of the easiest ways is to embed a 'DIV' block in the middle of where you want to insert the new HTML. Give the DIV block an ID, and then point the innerHTML to the file containing your new HTML code. Admittedly, there are some inheritance issues, and the HTML code generally has to be a complete HTML program in its own right. Method 2 is to use an OBJECT declaration, and use TYPE='text/html', along with a DATA pointer to your HTML source code file. Method 3 is to use the IFRAME (my favorite, for reasons that we needn't go into here). You simply point the src= to the file you want, and voila! you're in business. Your remark about the scrollbars is true -- but only if you use the default construct for IFRAME, and for the BODY declaration inside the child HTML program. For example, if you use <iframe name='blah-blah-blah' src='myFile.html' scrolling='no'>, and make sure that the BODY declaration of myFile.html also has scrolling='no' in it, your inserted window will not have scrollbars. It is also helpful to define the background window color (bgcolor) to be the same for your parent window and your iframe-included html object, and also to turn off the borders. [There are also some geometry issues, but they are easy to beat]. If you want a detailed explanation of what is necessary to invisibly weld an iframe included HTML document into a parent HTML document, I'd be glad to do a tutorial on it sometime. Most books I've seen are clueless on the details of this, and also ignore parameter passing to and from an iframe-included block. (Generally it follows much the same rules as a regular FRAME block). Some folks use OBJECT to do this, but I can tell you up front that passing variables to/from the child object this way is a nightmare, and not to be considered. For the inclusion of Java applets, multimedia objects, and the like, OBJECT is the best method available -- but for including reusable HTML modules, it sucks like a vaccuum cleaner on overdrive. [PARAM doesn't work worth a darn with child HTML code]. Of course, if you are allergic to IFRAMEs, you can simply use the file input routines in JavaScript, read in the source file line-by-line, and then use a subroutine to write each line back out to document.write() as a parameter. Be sure to escape everything, or else something might get whacked on transfer.* [*Some browsers require a signed script to do a direct file read with JavaScript, or so I understand]. Personally, I prefer the IFRAME. -- Dave Lovering DEV wrote: > > Des anypone of you know how I can implement a server side include file > flexibility on the client side ? What I mean by that is this; > > <Script src='File.js'></script> does absolutely the exact thing I have in > mind except that the requested content must be in a JS format. As a result > of this condition, if you happened to have a content in html to display ( > which is the most of the case ) , you have to transform it so it does the > job using document.write commands. > > Of course one alternative to my pure html pull wish is to tap into iframe's. > > For example , following will do the trick.. > > <script> > var sFile='/mycontent.HTM' > </script> > > some html > > <script>document.write "(<iframe src='" + sFile + "'></script> > > But this will cause the scroll bars to come on in the midlle of the page in > the case that the sFile content is lengthy. That's the price you pay for > that includability. > In a server side include however, you never run into this scroll-bar > situation. > > Does dhrml or some other technology other than iframe's help me in any way > ? > > Thanks > > _______________________________________________ > Javascript mailing list > Javascript@xxxxxxxxxx > https://lists.LaTech.edu/mailman/listinfo/javascript
- Follow-Ups:
- References:
- [Javascript] Where to learn JS best practices & style
- From: Michael Dougherty
- [Javascript] Any creative way to pull html content same way js files are pulled
- From: DEV
- [Javascript] Where to learn JS best practices & style
- Prev by Date: [Javascript] Where to learn JS best practices & style
- Next by Date: [Javascript] window confirmation
- Previous by thread: [Javascript] Any creative way to pull html content same way js files are pulled
- Next by thread: [Javascript] Any creative way to pull html content same way jsfiles are pulled
- Index(es):