Sub-pages should open in an Inline Frame

Do you want to share WYSIWYG Web Builder tips, tricks, tutorials or useful HTML code? You can post it here...
(no questions or problems please, this section is not monitored by support).
Forum rules
This section is to share tips, tricks and tutorials related to WYSIWYG Web Builder.
Please do not post questions or problems here. They will not be answered.

PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901
Post Reply
User avatar
kees
 
Posts: 48
Joined: Mon May 23, 2005 7:36 pm
Location: Soest - NL

Sub-pages should open in an Inline Frame

Post by kees »

Suppose you create your site using an Inline Frame with several sub-pages. How can you assure that the sub-pages are always opened inside the Inline Frame?

Let's assume that the main-page is called index.html, the Inline Frame is called IFrameName, the default sub-page is called sub_1.html and that all pages are in one directory.

First all sub-pages need some JavaScript.
1. Bring up the Page HTML dialogue, select 'Between Head Tag' and insert this:

Code: Select all

<script type="text/javascript">
 if (self == top) top.location.href = './index.html?' + escape(self.location);
</script>
Then the index-file (with the iframe) needs some changes.
2. Bring up the Inline Frame Properties dialogue and change it to:
- Name: IFrameName
- Link To: Web Site
- URL: empty, remove all text
3. Bring up the Page HTML dialogue.
3a. Select 'Between Head Tag' and insert this:

Code: Select all

<script type="text/javascript">
 if (top != self) top.location = self.location;
 var file = location.search ? unescape(location.search.substring(1)) : "./sub_1.html";
</script>
3b. Select 'Inside Body Tag' and insert this:

Code: Select all

onLoad = "self.IFrameName.location.href = file"
Note:
Seeing that the inserted JavaScript also works when you preview the page, you must set the 'Preview Scope' to 'Entire Web Site' (Tools->Options->Preview). A sub-page always calls up the main index.html .
Patr100
 
 
Posts: 115
Joined: Tue Dec 25, 2007 10:52 pm

Post by Patr100 »

I've been looking at this. For various reasons I have had to produce a page with another program outside of WB5 (which I cannot import) and so it is in another folder.
How would this need to be altered to do the same?

-
User avatar
kees
 
Posts: 48
Joined: Mon May 23, 2005 7:36 pm
Location: Soest - NL

Post by kees »

If the concerning page is a sub-page (shown in the Inline Frame), then you must insert the code at step 1.
This code must be placed between <head> and </head>.

If the concerning page is in a folder, then replace

Code: Select all

./index.html
with

Code: Select all

/index.html
genieuk
 
 
Posts: 129
Joined: Fri Mar 06, 2009 2:10 am

Post by genieuk »

Hi,

I been looking for something like this.

Some questions thou.

The first piece of code in your post,

Code: Select all

<script type="text/javascript">
 if (self == top) top.location.href = './index.html?' + escape(self.location);
</script>
where it says /index.html?

do i replace that with the page i want people to be taken to?

My inline frame is on a page called tutorials.php so do i replace index.html with tutorials.php ?

also what about the ? after the .html do i need to keep that there?

and this code:

Code: Select all

<script type="text/javascript">
 if (top != self) top.location = self.location;
 var file = location.search ? unescape(location.search.substring(1)) : "./sub_1.html";
</script>
where it says sub_1.html

do i replace that with the main webpage page name that is opended in the inline frame?

If you look here you will see what i am trying to do, it may make it more clear

viewtopic.php?t=17629

Thank you,
Mathew
User avatar
kees
 
Posts: 48
Joined: Mon May 23, 2005 7:36 pm
Location: Soest - NL

Post by kees »

genieuk wrote:My inline frame is on a page called tutorials.php so do i replace index.html with tutorials.php ?
Yes.
genieuk wrote:also what about the ? after the .html do i need to keep that there?
Yes, of course. Why else should it be there?
genieuk wrote:where it says sub_1.html
do i replace that with the main webpage page name that is opended in the inline frame?
Yes.

All these questions are explained in the article:
Let's assume that the main-page is called index.html, the Inline Frame is called IFrameName, the default sub-page is called sub_1.html and that all pages are in one directory.
genieuk
 
 
Posts: 129
Joined: Fri Mar 06, 2009 2:10 am

Post by genieuk »

Am i missing something here?

When for example someone clicks on the webpage link in google that is in an iframe it will show the page with no navigation menu etc,

i want so when someone accesses the URL directly it takes them to the page where the inline frame is,

i have tutorials.php that has a slide menu and inline on it, when someone clicks on example clean-install in slide menu it shows the clean-install.html webpage in the inline frame.

now if i access the link directly it will show a rather horrible page as it has no navigation menu etc.

now is this tip suppose to when someone tries accessing the page directly redirect them to tutorials.php in my example so they cannot view the page directly with no navigation menu etc?

i done what was said, and if i access page directly well i see nothing different. It does not take me back to page where the inlineframe is or anything

Thanks
Mat
User avatar
kees
 
Posts: 48
Joined: Mon May 23, 2005 7:36 pm
Location: Soest - NL

Post by kees »

genieuk wrote:now is this tip suppose to when someone tries accessing the page directly redirect them to tutorials.php in my example so they cannot view the page directly with no navigation menu etc
Yes.

What is the url of your site? Then we can take a look at what you did.
genieuk
 
 
Posts: 129
Joined: Fri Mar 06, 2009 2:10 am

Post by genieuk »

Hi,

It does work i got it mixed around stupid me.

when i tried accessing the vista-clean-install.html page it took me to the tutorials.php page.

when i tried accessing the vista-clean-install.html directly it redirected to iframe page (tutorials.php) and the link looked like this: (i removed my url)

http://www.mydomain.com/tutorials/tutor ... stall.html

Is it possible for it, when it takes you to the page the iframe is on for it to select the page the person originall wanted to see?

I was thinking, if someone clicked on a link in google let's say, now it will re-direct them to the page where the iframe is, this is great of course but wondering could it also select the page they wanted to view in the iframe on redirection?

or is it not possible?

Thank you,
Mathew
User avatar
kees
 
Posts: 48
Joined: Mon May 23, 2005 7:36 pm
Location: Soest - NL

Post by kees »

genieuk wrote:Is it possible for it, when it takes you to the page the iframe is on for it to select the page the person originall wanted to see?
That's exactly how it works. Doesn't it work that way on your site?
genieuk
 
 
Posts: 129
Joined: Fri Mar 06, 2009 2:10 am

Post by genieuk »

HI,

No, what it does is if i directly access the page it takes me to the tutorials.php page which has the iframe on but does not load the page in the iframe unless the user clicks on the tutorial they want on the slide menu.

Here you go

Link Removed - Site Not Yet Done ;)

see there, that is the page with i frame.

Now, click on any of the tutorials in the slide menu, it will of course load in iframe, for example click on vista clean install.

but it wont load the tutorial in the iframe.

Thank you,
Mathew
Last edited by genieuk on Mon Mar 16, 2009 6:40 pm, edited 1 time in total.
User avatar
kees
 
Posts: 48
Joined: Mon May 23, 2005 7:36 pm
Location: Soest - NL

Post by kees »

In step 3b you inserted this:

Code: Select all

onLoad = "self.IFrameName.location.href = file"
But the name of your Inline Frame is not IFameName. Your Inline Frame is named InlineFrame1.

The name in the code must be the same as the Inline Frame name.
genieuk
 
 
Posts: 129
Joined: Fri Mar 06, 2009 2:10 am

Post by genieuk »

Thank you,

Works Perfect.

Sorry, i dont know how i did not miss that,

Thanks ever so much :D

Mathew
User avatar
kees
 
Posts: 48
Joined: Mon May 23, 2005 7:36 pm
Location: Soest - NL

Post by kees »

cajosx wrote:and how to use this code in several pages ?
Step 1 should be done for all sub-pages.
cajosx wrote:And if have more than one inlineframe, do i have the code to each iframe ?.
Yes.
The name of the concerning Inline Frame should be adapted in step 3b.
But mind this solution does not work for multiple Inline Frames on one page.
cajosx wrote:Does google index the content ?.
Google will index all pages that can be found by following normal hyperlinks. Google does not find pages via JavaScript navigation.
So, if you have JavaScript navigation, also include the 'Text menu' on your pages.
Patr100
 
 
Posts: 115
Joined: Tue Dec 25, 2007 10:52 pm

Post by Patr100 »

I just added the necessary first part

Code: Select all

<script type="text/javascript"> 
 if (self == top) top.location.href = './index.html?' + escape(self.location); 
</script
to my subpage and previewed and it already seems to work OK so do I really need the additional script on the inline frame page itself?
User avatar
kees
 
Posts: 48
Joined: Mon May 23, 2005 7:36 pm
Location: Soest - NL

Post by kees »

If you only add the code on the subpage, then the main page will be loaded plus the default subpage.

If you want the chosen subpage in the Inline Frame, then you should perform the steps for the main page.
Patr100
 
 
Posts: 115
Joined: Tue Dec 25, 2007 10:52 pm

Post by Patr100 »

Right thanks I think I just need the script on the sub pages so anyone finding them on Google will get taken to a navigation page.
User avatar
kees
 
Posts: 48
Joined: Mon May 23, 2005 7:36 pm
Location: Soest - NL

Post by kees »

Patr100 wrote:Right thanks I think I just need the script on the sub pages so anyone finding them on Google will get taken to a navigation page.
... and did not get the page they were looking for :?

I would advice to perform the modifications on the main page as described.
Patr100
 
 
Posts: 115
Joined: Tue Dec 25, 2007 10:52 pm

Post by Patr100 »

Yes you're right - I just thought as long as they find the nav they can make their own way but its not right to do that.
I'm having a slight problem so I may return when I have more time.

Does the following code need to be modified?

Code: Select all

onLoad = "self.IFrameName.location.href = file"
User avatar
kees
 
Posts: 48
Joined: Mon May 23, 2005 7:36 pm
Location: Soest - NL

Post by kees »

Patr100 wrote:Does the following code need to be modified?

Code: Select all

onLoad = "self.IFrameName.location.href = file"
Yes.
IFrameName should be changed to the name of your Inline Frame.
Patr100
 
 
Posts: 115
Joined: Tue Dec 25, 2007 10:52 pm

Post by Patr100 »

Thanks that was the bit I missed -
haakoo
 
 
Posts: 189
Joined: Fri Apr 25, 2008 8:02 am
Location: Groningen/NL

Post by haakoo »

Kees,

Small request to you.
Is it possible to add a variable to the javascript that can be a trigger for a javascript in the index page?

crude example of what i'm looking for
-put a variable called var sd on sub_1.html
-have it display in an editbox with document.getElementById(Editbox1).value =sd;
This to execute a javascript function on index page

Hans
haakoo
 
 
Posts: 189
Joined: Fri Apr 25, 2008 8:02 am
Location: Groningen/NL

Post by haakoo »

Allready figured out how to do it.

Hans
User avatar
kees
 
Posts: 48
Joined: Mon May 23, 2005 7:36 pm
Location: Soest - NL

Post by kees »

FAVTdk wrote:what have I done wrong
Can you give the exact url of the main page (with the iframe)?
User avatar
kees
 
Posts: 48
Joined: Mon May 23, 2005 7:36 pm
Location: Soest - NL

Post by kees »

The inserted code at step 3a should be:

Code: Select all

<script type="text/javascript">
 if (top != self) top.location = self.location;
 var file = location.search ? unescape(location.search.substring(1)) : "./Velkommen/Velkommen.php";
</script>
electrochrisso
 
 
Posts: 45
Joined: Mon Aug 19, 2013 8:39 am
Location: Darling River

Re: Sub-pages should open in an Inline Frame

Post by electrochrisso »

Not sure if I am missing something here, but all this can be done using the standard options provided by Web Builder, No!
WYSIWYG THE GREATEST Web Builder EVER
User avatar
Pablo
 
Posts: 22429
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Sub-pages should open in an Inline Frame

Post by Pablo »

Please note that this topic is more than 5 years old. 'Kees' is no longer active on this forum.
However the script still works.
mnwitten
 
 
Posts: 37
Joined: Sun Aug 17, 2008 10:29 am
Location: Newfoundland, PA
Contact:

Re: Sub-pages should open in an Inline Frame

Post by mnwitten »

I came up with this little piece of code that may help anyone interested.

<script>
// Get where the user came from
referrer = document.referrer.toLocaleLowerCase(); //new URL(document.referrer).hostname;
// If it isn't onlinewatersports...
if (referrer.indexOf("onlinewatersports")==-1)
{
// send them to the main website page
window.location="http://www.onlinewatersports.com";
}
}
</script>

It simply captures where the user browsed from. In this case...was it onlinewatersports? if it wasn't...it redirects them to the main page. I modified the code to post here so consider this untested.
Post Reply