Forum Moderators: open

Message Too Old, No Replies

Iframes vs. JavaScript Layers

which is better to use to display content with scrollbar

         

glaze

7:45 pm on May 31, 2004 (gmt 0)

10+ Year Member



Another developer is telling me it is more "correct" to use Javascript layers to display small panes of scrollable content rather than using iFrames. Is this true? What are the indications for each? Is there an existing discussion on this already?

Thanks for any help.

tedster

9:22 pm on May 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here are some comments, top-of-the-head

1. Javascript will reach a smaller audience than an iframe.

2. When you use layers (divs) all the information is in one document. There is both a search engine and a semantic value in using iframes so that separate topics are kept in separate documents.

3. If any of these scrollable windows hold a significant amount of information, using divs will fatten up the file size of the HTML. If there are many, it can require a prohibitive amount of download time.

glaze

9:52 pm on May 31, 2004 (gmt 0)

10+ Year Member



I've heard criticism that iFrames allow search engines to index their contents which may not be desirable.

Is there a work around this? I know fo the robot.txt file but I've heard that Google ignores this.

tedster

10:24 pm on May 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Most search engine crawlers will obey robots.txt with perhaps a few accidents. You can also use the robots meta tag in the <head> for extra backup and fine tuned control.

<meta name="robots" content="INDEX,FOLLOW"> or NOINDEX, or NOFOLLOW in any combintion you want

Here you're looking at another difference between divs and iframes. If you use divs, then the whole document is treated the same way. Using iframes allows you more granular control of what the SE will index.

glaze

2:07 am on Jun 1, 2004 (gmt 0)

10+ Year Member



tedster, thank you for the informed responses.

Could you please give me a quick example of wht you mean by this:

"Using iframes allows you more granular control of what the SE will index."

Thanks.

tedster

2:49 am on Jun 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's what I mean by "granular."

Each bit of content displayed in an iframe is actually an independent HTML document with its own URL. Because of this you can apply robots.txt and the robots meta tag differently in regard to each document. You can allow spiders to index some of the documents and not others -- or to follow links in some documents and not others. You can mix and match according to your specific needs in each case.

However, when you use divs you put all the information within one HTML document, at one URL. So you can only set up spidering and indexing restrictions the same way for ALL that information.

glaze

4:22 pm on Jun 1, 2004 (gmt 0)

10+ Year Member



What if I have content in an iframe that I want indexed with my site but I don't want the SE to index just that HTML page (since it will not include navigation from the parent page)?

Thanks.

tedster

1:50 am on Jun 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Search Engines index HTML documents - and not what appears to be "a page" visually, since that can be composed of many separate documents in the case of frames.

You have at least a couple resorts:

1. Use scripting to detect if the page is orphaned - if it is put it back into an iframe on its appropriate page. There's a javascript solution in message #21 of our Generic Javascript thread [webmasterworld.com]. It's for a regular frameset, but the logic is easy to adapt for an iframe. Server side scripting would be a surer fix if you can do it -- would work even if the user has js turned off.

2. Bite the bullet and include some basic nav in the orphaned page -- or you might also use javascript to write navigation into the doc only if it's not in an iframe.

One word of caution -- search engine spiders are not so good at following the initial src=page.html attribute of an iframe, although they certainly will follow any links that target that iframe and change the displayed document. So I'd suggest a straight HMTL link somewhere (site map perhaps) for any HTML docs that only appear in the src attribute of the iframe.