Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to load a page in a layer.

Status
Not open for further replies.

vcherubini

Programmer
May 29, 2000
527
US
Hello:

I am working on a project and I need to know if there is a way to load a webpage into a layer (div, or span). Is this possible?

I have some code working so far, but it loads the page into a new window:

[tt]
<html>
<head>
<title>
load page</title>
</head>
<script language=javascript>
function loadpage() {
open(&quot;}
</script>
<body>
<div id=placetoloadpage onmload=&quot;loadpage()&quot; style=&quot;border:1px solid black; width:500px; height:500px;&quot;>

</div>
</body>
</html>
[/tt]

I know that it is basic, but I thought that it would work.

Any help is appreciated.

Thanks,

-Vic
vic cherubini
malice365@hotmail.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director
====
 
since you are not referencing any object when you call open, it is going to look (through the scope chain) to see what object has a method open. In this case it is the window (global) object, so you are just calling window.open(&quot;somepage.htm&quot;) basically, which is why you ended up with a new window.

There are 3 solutions I know of which will solve your problem, all of which (I think?) require that the page you are trying to load is on the same domain (server?) as the page doing the loading.

IE4+/NS6:

load the code in a hidden frame, and pull the contents out of it piece by piece and assign it to the innerHTML property of your 'layer'

IE5.5 - the download behavior (best):


and, if you must support NS4.X (which < 10% of total pop uses now) i think you can assign a src to a layer, something like:

document.layers.layername.src=&quot;somefile.htm&quot;

Also, you could maybe (IE4+?) use a borderless i-frame.

jared@aauser.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top