[thelist] Use JavaScript includes to insert PHP into a site?
Keith
cache at dowebs.com
Thu Jan 10 22:01:28 CST 2002
> Yeah, the log reports are at 55% Netscape users (mostly 4.7)... so I'd
> like to avoid iFrame for my particular case. But I _was_ thinking
> that that would work too, and would be more practical for _large_
> clumps of html to poop out to the browser....
>
Try both. If you place the tag for an external javascript inside an
iframe tag Explorer will give you the iframe and ignore the js tag.
Netscape will ignore the iframe and give you the js. I've never seen
documentation that IE *should* ignore the enclosed js tag, it just
does, at least in 5.5.
<iframe src="inc.cgi?iframe" width=150 height=150>
<script language=javascript src="inc.cgi?js"></script>
</iframe>
As for pumping out _large_ clumps of html... remember your
browser reads machine readable output as well as it reads human
readable. A 50K page in 200 lines or a 50K page in one line
makes no difference to the browser. When i've used the above tag I
tell the cgi which format to return with the query string. If it's in js then
I strip all line breaks and escape all double quotes and drop the
variable inside one document.write(""), otherwise just return the text
as is.
What's the advantage? Newer IE browsers get the iframe even with
js turned off, all others get the js if they have it enabled. Netscape
users with js turned of, that's a room full of people in a city of 100
million, a smaller group that you get with just a js tag.
The big disadvantage, you've gotta have excess page real estate
to work with. An iframe works just like a frame, it's a defined chunk
of your real estate. If you're returning text and it doesn't fit because
of user preference you'll get scrollbars that may screw up the rest of
the design. Also, the contents of an iframe wont flow with the rest of
the content. If you're embedding in a tightly laidout out page all other
layout has to be built to flow around the iframe space. And using
percent width and height for the iframe just aggravates the first
objective of trying to use only the space that the content dictates.
Anyhow, if you have the real estate, it's worth trying unless someone
knows of a browser that pukes when seeing the js tag inside of the
iframe tag.
keith
More information about the thelist
mailing list