Forum Moderators: open

Message Too Old, No Replies

force iframe to load

         

gpig

10:17 am on May 24, 2004 (gmt 0)

10+ Year Member



in refernce to this post

[webmasterworld.com...]

what do you do when "if you have multiple content pages and want the container page to reload the correct content page"?

im stumped on this and haven't found a sartisfactory anser yet!

LangDesigns

2:10 pm on May 24, 2004 (gmt 0)

10+ Year Member



I don't understand what you're asking.

Do you want it so wheny ou click a link that page loads in the iframe?

gpig

2:23 pm on May 24, 2004 (gmt 0)

10+ Year Member



sorry, i want a content page to load itself into an iframe when called whilst replacing the original content page withing the iframe,

make sense

DrDoc

2:33 pm on May 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to Webmaster World -- both of you! :)

In the orphaned content page, use a JavaScript to change the location.href if not within a frameset:

<script type="text/javascript">
if(top==self) {
top.location.href = "index.html?page=thisone";
}
</script>

...assuming the page with the iframe is called index.html. Then just use PHP (or some other server side scripting language) to set the iframe source, depending on the

page
variable.

gpig

3:17 pm on May 24, 2004 (gmt 0)

10+ Year Member



lets pretend im thick for a sec, and can you walk me through the code slowly, cheers

DrDoc

3:21 pm on May 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<iframe src="<?php
echo ($_GET['page']?$_GET['page']:"someotherpage") . ".html";
?>"></iframe>

Just replace "someotherpage" with whatever the default page is supposed to be... and replace "thisone" in the JavaScript with the name of the orphaned content page (minus the .html part).

LangDesigns

3:30 pm on May 24, 2004 (gmt 0)

10+ Year Member



This may be what you want, I still don't fully understand you.

<iframe src="STARTPAGE" width="pixels" height="pixels" name="NAME-OF-IFRAME"></iframe>

<a href="pagetwo.html" target="NAME-OF-IFRAME">Page Two</a>

That will open page two in the iframe.

gpig

3:49 pm on May 24, 2004 (gmt 0)

10+ Year Member



cheers but drdoc is on the case but unfortnately its not quite working, but it really is because i am horrendously dim::

the pages i am using are

index.php (main page with iframe called FRAME1)

indextext.php (default content page)

parkhopper.php (content page i wish to load in and replace indextext.php)

DrDoc

3:52 pm on May 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



index.php

<iframe src="<?php
echo ($_GET['page']?$_GET['page']:"indextext") . ".php";
?>"></iframe>


parkhopper.php

<script type="text/javascript">
if(top.location.href==self.location.href) {
top.location.href = "index.php?page=parkhopper";
}
</script>

gpig

4:11 pm on May 24, 2004 (gmt 0)

10+ Year Member



no luck, when you call parkhopper.php it loads the index.php as requested but the indextext.php stays in the frame

dagnabbit!

DrDoc

4:24 pm on May 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you using the PHP snippet to set the iframe src attribute?

gpig

7:42 pm on May 24, 2004 (gmt 0)

10+ Year Member



yeah im using the code just as you said there

DrDoc

7:46 pm on May 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you use the $page variable elsewhere?
You sure you don't have another src attribute for the iframe?
What does a View Source tell you?

gpig

8:29 pm on May 24, 2004 (gmt 0)

10+ Year Member



nope i dont use the page variable and in view source on the index,php, it just has the indextext.php in the srcof the iframe as if i had coded it in html

DrDoc

8:39 pm on May 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What's your PHP version?

gpig

8:51 pm on May 24, 2004 (gmt 0)

10+ Year Member



gawd its a from a webhoster above 4

gpig

9:18 pm on May 24, 2004 (gmt 0)

10+ Year Member



version 4.3.4 to be exact

DrDoc

9:39 pm on May 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you simply echo
[b]$_GET['page'][/b]
...do you get anything?

gpig

8:39 am on May 25, 2004 (gmt 0)

10+ Year Member



<iframe src="<?php echo $_GET['page'];?>"></iframe>

didnt do nothing im afraid

gpig

8:56 am on May 25, 2004 (gmt 0)

10+ Year Member



FIXED it i was missing a variable in the head of the content page thanks ever so much:)))))))

DrDoc

2:43 pm on May 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Great! Glad it works ;)