Solved

Insert page to template

Posted on 2008-06-25
15
202 Views
Last Modified: 2010-04-25
I have a template created in dreamweaver and would like to insert a forum page that has been created by my service provider.
in the forum page there is a link to my home page.
If I insert the page by iframe then clicking on the link to my home page make the new page includinjg template apear within the origional template, so seeing a template within a template.
If I use PHP "include" the the javascript in the template does not work correctly.
I have tried Frames but these do not appear to work
Any suggestions on how to include an external (forum) page in a template created by dreamweaver.?
0
Comment
Question by:Simon Cripps
  • 8
  • 6
15 Comments
 
LVL 5

Expert Comment

by:codeQuantum
ID: 21871177
Frames should work. What was the problem with them?
0
 
LVL 4

Accepted Solution

by:
msfletch earned 500 total points
ID: 21872635
Keep the iframe and try adding the following to the <HEAD> of your Home Page:

<script language="JavaScript" type="text/javascript">
<!--
function bustOut()
{
    // check for differences between window location and frame location
    if (top.location != location) {
        // make window location same as frame location ... in other words, bust out of frame
        top.location.href = document.location.href ;
  }
}
-->
</script>

0
 
LVL 4

Assisted Solution

by:msfletch
msfletch earned 500 total points
ID: 21872640
... and this to the <BODY> tag:

<body onLoad="bustOut();">
0
 

Author Comment

by:Simon Cripps
ID: 21887950
<P>This does not appear to work attached is a link to show what is going wrong</P><P><A href="http://www.netballnetball.com/Community/Netball_Forum.html">http://www.netballnetball.com/Community/Netball_Forum.html</A></P><P>if you click on Home in the forum you will see the issue.</P><P>does this help explain the issue</P><P> </P>
0
 
LVL 4

Expert Comment

by:msfletch
ID: 21889178
Crippsy,

Is there a reason you switched the order of the elements in the last line from:

top.location.href = document.location.href ;

... to:

document.location.href = top.location.href;

That definately won't work. Did you try it both ways?
0
 
LVL 4

Expert Comment

by:msfletch
ID: 21889202
The way originally written works fine for me. you can test it with the two attached test file codes. Try running it with    onLoad="bustOut();"    in and out of the BODY tag and see the difference.
-------------------------------------------------

test1.htm

-------------------------------------------------
 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 

<html>

<head>

	<title>Untitled</title>
 

	<script language="JavaScript" type="text/javascript">

	<!--

	function bustOut() {

	    // check for differences between window location and frame location

	    if (top.location != location) {

	        // make window location same as frame location ... in other words, bust out of frame

	        top.location.href = document.location.href;

		}

	}

	-->

	</script>
 

</head>
 

<body onLoad="bustOut();">
 

<iframe height="200" width="200" frameborder="1" src="test2.htm"></iframe>
 

</body>

</html>
 

-------------------------------------------------

test2.htm

-------------------------------------------------
 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 

<html>

<head>

	<title>Untitled</title>

</head>
 

<body>
 

<a href="test1.htm">Test Breakout</a>
 

</body>

</html>

Open in new window

0
 

Author Comment

by:Simon Cripps
ID: 21895597
yes I was just trying out variations.
As far as I can see the source is now as you suggest but is not working.

0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 4

Expert Comment

by:msfletch
ID: 21896778
OK ... we'll use parent instead of top. Try the following instead. Just include it in the head and forget about the onLoad from the body.
<script language="JavaScript" type="text/javascript">
 

if (parent.frames.length > 0) {

    parent.location.href = self.document.location

}
 

</script>

Open in new window

0
 

Author Comment

by:Simon Cripps
ID: 21897652
Narowing this down now.
First of all it did not like onLoad and all had to be lower case onload.
I tried the suggestion above of not using onload an nothing happened
using if (parent.frames.length > 0) {...) keeping the onload made the page continualy refresh

basically still stumped
0
 
LVL 4

Expert Comment

by:msfletch
ID: 21903603
Interesting about the case. What is the operating system of the sevrer?

Did you try the lower-case "onload" with the "top" code?

When you say it constantly refreshed, do you mean the iFrame refreshed or the age as a whole refreshed?
0
 

Author Comment

by:Simon Cripps
ID: 21903807
I'm using 1and 1 so a unix box
I tried onload with the top code
and the whole page refreshed and not just the I frame
0
 
LVL 4

Expert Comment

by:msfletch
ID: 21910970
That is extremely strange that the code I have given you does not work. I have tested both and they work great on my end, so I am not sure what the difference could be.

One thing is, I looked at your code and I am not sure if what I am seeing is correct, but it seems that you have added the Javascript and the "onload" to the page:

http://www.netballnetball.com/Community/Netball_Forum.html

... but the page that actually opens in the <IFRAME> is:

http://www.netballnetball.com/index.html

The Javascript and onload need to be added to the second page to make them work. Have you tried that?

Another thing that could be causing issues is if the whole site was within a frame to begin with. This does not seem to be the case, but the scripts I gave you check if the opened page is not in the top level of the window (in otherwords not within a frame), and if it is, then it reloads the top level with the URL of the current window. If however, the top level created a frame by default and loaded the home page into that frame, then it would continually refresh the page because it would never be in the top level.

If this were the case, and again looking at the pages it does not seem to be so, then adding the frame breakout to the frameset (as opposed to a page loaded into a frame) would solve the issue. Again, I don't think this is the case, but worth verifying on your end.
0
 

Author Comment

by:Simon Cripps
ID: 21911489
You are very good, you got it right first time and explaine dmy error above.
I put the code in the page with the Iframe and not the home page it was calling. it now is it in the home page that is being called and it works.
Many thanks for your patients and apologies for miss reading your solution.
0
 

Author Closing Comment

by:Simon Cripps
ID: 31470809
Again many thanks appologies for not seing that the code should go i the page being called and not the calling page. Cheers
0
 
LVL 4

Expert Comment

by:msfletch
ID: 21911626
Glad you got it working. =)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now