PDA

View Full Version : iFrames



masterstanf2k
September 14th, 2003, 10:25 AM
This is more of a general HTML question. Not really a question regarding any of the apps. Question- I have a website that's got its main content loaded in an iframe. I want to be able to link to the iframe page in a URL. I might sound confusing here, but this is what I mean- http://mysite.com?body=help.html. ('body' being the name of my iframe, and = being the page to open in it.) NOTE: This is an example, it DOES NOT WORK. That's why I'm asking how should it be done correctly so that it works? THX a lot guys ;)

abzoid
September 14th, 2003, 11:01 AM
What you're trying to do isn't possible with just HTML, you'd need to use some form of server side scritping language to process the "body" parameter you're passing in the URL, and insert the appropriate code to load that page in the iframe before it serves the web page to the user.

ASP, PHP, etc. could do that fairly easily.

You may also be able to do it with some fairly messy javascript, but that's not my forte. There are a few others here that are better able to address that issue.

masterstanf2k
September 14th, 2003, 11:12 AM
OK, JScript, I'll wait for other people to respond, that knkow JavaScript, but, would you mind explaining to me how it'll work in PHP??

abzoid
September 14th, 2003, 11:26 AM
PHP and ASP would both work the same way. A series of statements would first read the passed parameter from the URL string then insert the proper HTML code into the page to make the desired page load in the iFrame. You'd need to be hosted on a web server that supported either PHP or ASP since the page would need to have a .php or .asp file extension instead of .htm.

masterstanf2k
September 14th, 2003, 12:24 PM
I am.... plz give me a script or something, plz. Thank You ;)

abzoid
September 14th, 2003, 12:42 PM
Here's the code in ASP


At the top of your page, before the HEAD:
<%
Dim pagename
If request.querystring("body") <> "" Then
pagename = request.querystring("body")
Else
pagename = "default_iframe.htm"
End If
%>

In the Body of your page:
<iframe id="framename" width="50%" height="200" frameborder="1" src="<%= pagename %>" scrolling="yes"></iframe>

λ
September 14th, 2003, 01:10 PM
in PHP:



<iframe id="framename" src="<?php if(isset($_GET['body'])){
echo($_GET['body']);
}else{
echo("default_page.htm");
} ?>" />

abzoid
September 14th, 2003, 01:33 PM
njs12345, your code works great as long as no one links to the page without the parameter string. That's why I included the IF...THEN...ELSE at the top, so that a default page for the iFrame would be used in that situation.

λ
September 14th, 2003, 01:37 PM
the script should now do exactly the same :)

abzoid
September 14th, 2003, 01:44 PM
:thumb:

masterstanf2k
September 14th, 2003, 02:06 PM
erm... ok, how about I make this easier to understand. HEH! OK, I've got my site- http://edgeirc.com. If you click on any of the nav bar links, you go to the page, through the iframe. I want it to work similarly but I can tell people away from the site to go here: http://edgeirc.com(whatever to make it work). Anyways... what do I do now? Would any of you mind writing a script for me? heh...

abzoid
September 14th, 2003, 02:11 PM
Originally posted by masterstanf2k
...Would any of you mind writing a script for me? heh... If you're interested in purchasing my services just click my footer :}

masterstanf2k
September 14th, 2003, 02:26 PM
this is a support forum :( Would you mind... plz...

abzoid
September 14th, 2003, 02:27 PM
support = helping, not doing it for you

I get paid quite well for custom scripting

masterstanf2k
September 14th, 2003, 02:36 PM
I C.....

reverendflash
September 14th, 2003, 02:37 PM
If you just want a script, then go to www.webmonkey.com, and do a search.

We try to teach how to do it here...

thanks for understanding.

Rev

masterstanf2k
September 14th, 2003, 02:49 PM
ok... fine... now, instead of writing a script.. can I be taught how to make one? heh...

abzoid
September 14th, 2003, 05:35 PM
<img src=http://www.unseenwings.com/images/baby-walking.jpg>

masterstanf2k
September 14th, 2003, 06:16 PM
:)