hey guys
i'm workin on my profile and it uses iframes. i know they have compatibility issues and stuff but i just couldn't think of another way to get the same effect. then i thought that maybe i could have, within a javascript, a variable... ok just look
function writeframe(url){
var content=eval("<?php include(/""+url+"/"); ?>")
document.all['content'].innerHTML=content
}
i know that's javascript and this is the php forum but it has to do with php also so i wasn't sure where to put it. anyway... that script obviously doesn't work. maybe it's just a syntax error or something... or is there no way to get that effect? by the way, 'content' is the name of(obviously) the variable, and the id of a div tag in the body, which u prolly figured out by now... so anyway... tia
boBwhat? you can't load a page like that.
if you want the same effect as a iframe then use the include() ***ntion in phpi am using the include() function. if i just include a file inside a div tag, it would work but i want it so that i can click a link and say it linked to home.html the link would be "#" and the onlick would be writeframe('home.html') i want it to include that file inside the div, not just have it in an iframe. so i was trying to evaluate <?php include("home.html")?> and the 'content' variable would be that string.then it would write 'content' into the 'content' div. i think it would be possible, but not with the code i posted before...if I understand you correctly, it is impossible to do what you want.
use a switch case to include anything you want in that div.umm.. what is a switch case?http://us4.php.net/manual/en/control-structures.switch.phpand how do i use this? i understand it but what good does it do for me?like this
echo"<div>";
switch ($_GET['p']){
case "file1":
include("something.php");
break;
case "file2":
include("somethingelse.php");
break:
default:
include("default.php");
break;
}
echo"</div>";
that should work but I have no idea how you are loading the page. you can't set a target to the div so you need to load a file in the url like this
file.php?p=file1
that will load what ever you send to it. of course you have to change the names to suit what you need.oh ok that's simple enough.. thanks
i'm workin on my profile and it uses iframes. i know they have compatibility issues and stuff but i just couldn't think of another way to get the same effect. then i thought that maybe i could have, within a javascript, a variable... ok just look
function writeframe(url){
var content=eval("<?php include(/""+url+"/"); ?>")
document.all['content'].innerHTML=content
}
i know that's javascript and this is the php forum but it has to do with php also so i wasn't sure where to put it. anyway... that script obviously doesn't work. maybe it's just a syntax error or something... or is there no way to get that effect? by the way, 'content' is the name of(obviously) the variable, and the id of a div tag in the body, which u prolly figured out by now... so anyway... tia
boBwhat? you can't load a page like that.
if you want the same effect as a iframe then use the include() ***ntion in phpi am using the include() function. if i just include a file inside a div tag, it would work but i want it so that i can click a link and say it linked to home.html the link would be "#" and the onlick would be writeframe('home.html') i want it to include that file inside the div, not just have it in an iframe. so i was trying to evaluate <?php include("home.html")?> and the 'content' variable would be that string.then it would write 'content' into the 'content' div. i think it would be possible, but not with the code i posted before...if I understand you correctly, it is impossible to do what you want.
use a switch case to include anything you want in that div.umm.. what is a switch case?http://us4.php.net/manual/en/control-structures.switch.phpand how do i use this? i understand it but what good does it do for me?like this
echo"<div>";
switch ($_GET['p']){
case "file1":
include("something.php");
break;
case "file2":
include("somethingelse.php");
break:
default:
include("default.php");
break;
}
echo"</div>";
that should work but I have no idea how you are loading the page. you can't set a target to the div so you need to load a file in the url like this
file.php?p=file1
that will load what ever you send to it. of course you have to change the names to suit what you need.oh ok that's simple enough.. thanks