?
Solved

Insert page to template

Posted on 2008-06-25
15
Medium Priority
?
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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 2000 total points
ID: 21872640
... and this to the <BODY> tag:

<body onLoad="bustOut();">
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 

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
 
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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

765 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