1

The reason I want to use an IFRAME rather than a DIV (for example) is because I want this bit of the page to have a scrolling window...

The PHP page called by an ajax call supplies the content to an ajax success() method...

Obviously I could put the PHP page's output to a file... and then read this in by changing the src of the IFRAME... but I was just wondering if there was a way of loading an IFRAME's content another way.

Alternatively, is there any other HTML or JQuery or JQuery UI component which implements scrolling?

4

1 回答 1

0

As Mr. Bombastic says, this is best done via CSS using property overflow: scroll. You cannot access the contents of an iframe via JavaScript due to security restrictions.

If you are adamant that an iframe container is used to display the ajax result, you are going to have quite a bit of hoops to jump through. Just for an idea of how unnecessarily complex this could be, you could display a page in the iframe that you host on the same server. When you process your ajax success() logic on the iframe containing page, utilize node.js to push an update to the iframe page. Basically you'd be setting up a chat interface between the iframe parent and the iframe content pages. Using CSS overflow: scroll is much easier, more efficient on the server, and faster for the client.

于 2013-06-15T19:09:34.083 回答