Page Viewer | JavaScriptSource

Page Viewer

Elliot Khazon Nov 19, 2007


Use this script to load Web pages inside an iframe. Easy to set-up. Everything is adjustable to fit your Web site.

View the example here. [Opens a new page]


The variable "baseUrl" is the URL from which the other links begin.

The "id" is the page you want to load. The first id on the list must also be place in the showPage1 function:
showPage (document.getElementById ("placeItHere.php"));

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: pageViewer.js


Paste this code into the HEAD section of your HTML document.


Paste this code into the BODY section of your HTML document

Leave a Response


One reason you might want to do it this way is not to be tied to target="frame" at link creation. So, your page can either goto a different page or show it on the same page based on the function implementation.[br /]The idea is your function will decide how to deal with the information it is being passed, rather than the browser.[br /]One reason you would like to use iframes is because they are old-time xmlhttprequests or ajax. if you don't feel like writting an ajax library or you can't use one because you don't have enough server privileges (to install a library there) or your users are using old browsers iframes is a way to display dynamic content.

Elliot Khazon Feb 18, 2008

It works just fine for me, Kenneth, using FF and IE 7.

Lee Dec 4, 2007

Yes, Ian, there are different ways to accomplish the same task. This is one of them.[br /][br /]Also, sometimes you might want to display information and are not concerned about the search engines.

Lee Dec 4, 2007

It doesn't work if using it as an external javascript.

Kenneth Nov 29, 2007

This script looks great, but can't this be achieved using the code target="nameof form"? Also frames are not friendly for search engines as far as I know.

Ian Nov 26, 2007