View Full Version : Loading a HTML file into a DIV/IFRAME
Just as the title says.
I need to know the JS script required so that, when someone clicks a link, it will load the relevant HTML page into an IFRAME. I tried to Google it, but none of the code I found includes an explanation that I can understand, and anyway it didn't work. So I'm stumped.
Rep to the kind person who helped me.
Brother
08-12-2006, 08:13 PM
Arent iFrames a bit redundant nowadays?
Anyway, if you're just after the basic code, as far as I know, it's something like:
<iframe name="nameofiframe" src="whatyouwanttoload.html" width=# height=# frameborder=# target=nameofiframe></iframe>
You then have to embed this in your page HTML where you want it to appear. There's not really much to explain I don't think. If I'm off the mark, haven't answered you properly or there's something you don't understand let me know.
Arent iFrames a bit redundant nowadays?
Redundant? What is it replaced with now? I think I read somewhere that it doesn't comform with HTTP 4.x "Traditional" scheme, but I really would prefer not to use frames.
Anyway, I'm afraid what I want is a bit more complex than that, Brotherhood. I know that putting something in the src attribute will load that; what I want is that, when I click on a link somewhere, it will load that page inside the same iframe. In other words, I want it act like a frame... but without using the FRAME tags.
If you need visual aid, go here (http://sparc.mmu.edu.my/). Imagine that the big, black void in the middle is the IFRAME region. When I click on the Home button at the bottom, I want it load main.htm; and when I click on the question mark icon, I want it to load about.htm in the same IFRAME.
Nostalgicmix
08-12-2006, 09:10 PM
DIVs replaced iFrames heavily.
To be frank, I don't really see the difference between either.
I just want to get the job done before I get yelled at by the President. She's hot, but this is not the sort of attention that I want ;)
Nostalgicmix
08-12-2006, 09:32 PM
There is quite a difference. iFrames has limitations and DIVs exceed those limitations by far.
Minako
08-12-2006, 10:21 PM
Make the links look like this:
<a href="pagetoload.html" target="iframename">
That should do it.
Make the links look like this:
<a href="pagetoload.html" target="iframename">
That should do it.
Doesn't work. From what I read, the consensus is that it's impossible to do what I want without JavaScript.
And the "target" field generally accept only FRAME IDs, or any of the four default values (_blank, _parent, _top and _self)
Halp plz :(
Nostalgicmix
08-13-2006, 05:09 PM
Take a look at this old, inactive website of mine and tell me if that is your goal with the loading of the pages.
www.wispstudios.com/einherjar/
Edit: Use FireFox if you can.
Well yes, sort of...
But do I have to use php?
Nostalgicmix
08-13-2006, 08:38 PM
You do because it uses:
<? echo $content; ?>
However, the php is very simple and the only php you will have to use within the rest of the website.
The target uses "_parent".
Okay....
The code is... "confusing", to say the least. By that, I mean that when I viewed the site's source, I can't really make what it's trying to do.
If it's not too much trouble, laying out the important bits here (with maybe some explanation as to what I should modify) is much appreciated.
Brother
08-13-2006, 09:25 PM
If you're on about the source code of that site, PHP is server-side so you wouldn't be able to see it anyway.
Why don't you just download an eBook on website building or HTML/PHP or something? You'll be able to apply what you want immediately and you'll be able to understand it better.
After reading up on the subject, I came to a conclusion that the easiest way to do this is by using Javascript.
And not even someone who's as awesome (read : nerd) as I am can fully learn the language in one day. It's like trying to write an operating system in C++ after learning the language for a week
DIV does not replaced iframe. Two different elements there.
It's probably easier and better to do this in SSI. Do you have support?
Now to do what you want.
1. Put an iframe inside a div
2. <iframe src="#" height="100%" width="100%" name="nameofiframe" id="home"></iframe>
3. Then just target the attribute of id to a particular frame target="home"
Hope that works!!!
TeyRon
08-22-2006, 04:02 PM
DIV does not replaced iframe. Two different elements there.
It's probably easier and better to do this in SSI. Do you have support?
Now to do what you want.
1. Put an iframe inside a div
2. <iframe src="#" height="100%" width="100%" name="nameofiframe" id="home"></iframe>
3. Then just target the attribute of id to a particular frame target="home"
Hope that works!!!
that wont work, it should be
3. Then just target the attribute of id to a particular frame target="nameofiframe" notice the target name, chosing home will only result in either a new page opened on link click or the html file for the iframe just not loading
the target and name MUST be the same otherwise youll just end up getting the above error
DIV does not replaced iframe. Two different elements there.
It's probably easier and better to do this in SSI. Do you have support?
Now to do what you want.
1. Put an iframe inside a div
2. <iframe src="#" height="100%" width="100%" name="nameofiframe" id="home"></iframe>
3. Then just target the attribute of id to a particular frame target="home"
Hope that works!!!
Hell yeah, this actually works! THANKS A LOT!
You are duly repped for services to teh Amreh :heart:
Brother
08-24-2006, 11:16 AM
That's what I and Minako both put. :rolleyes:
No, both of you guys omitted the important part; the ID attribute. Although I wonder how that is different from "name"....
edit : wait, I'll get back to that. I need to check... the NAME attribute may or may not work. I need to retest the whole thing again.
In XHTML ID replaces name. To deal with older browser who hasn't caught up to that point yet you should probably use name and ID.
In my code I didn't mean to give ID a different name.
It doesn't matter if you target the link to nameofiframe or home, as long as it's link properly it should be fine.
vBulletin® v3.7.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.