The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Redirecting external links, To maintaing site layout
Druidor
post Nov 22 2006, 07:42 AM
Post #1





Group: Members
Posts: 2
Joined: 22-November 06
Member No.: 1,027



I have been trying to work this one out for a while & seem to be getting nowhere fast.

I have made a web site that has a single IFrame that is used to display all of the various pages as they are opened in the site. but I want to set it so that if a page is linked to from its direct point it will open up within this iframe as opposed to opening on its own.

I have instigated the following script that forces any externally linked pages to goto the default to the index of the site & hence the intro page but want it to open the linked to page instead.

<script>

if (parent.location.href == self.location.href){

window.location.href = 'http://www.philbune.clara.co.uk/index.htm'
}

</script>

Examples

Main site address:- http://www.philbune.clara.co.uk

page that does not redirect:- http://www.philbune.clara.co.uk/htm_pages/linux.htm

Page that redirects:- http://www.philbune.clara.co.uk/htm_pages/bittorrent.htm

All I want is for directly linked to pages to open in the IFrame as I intend it to do.

Any help would be apreciated as this is proving frustrating for a web designing noob. wacko.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Nov 22 2006, 08:02 AM
Post #2


.
********

Group: WDG Moderators
Posts: 9,650
Joined: 10-August 06
Member No.: 7



This is one of several reasons frames are best avoided:
http://htmlhelp.com/faq/html/frames.html#frame-context
http://htmlhelp.com/faq/html/frames.html#frame-problems

Better alternatives are suggested here: http://htmlhelp.com/faq/html/design.html#include-file
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Nov 22 2006, 08:02 AM
Post #3


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



You haven't put the script in either of the pages. http://www.philbune.clara.co.uk/htm_pages/news.htm just happens to be the page that initially loads in the iframe.

You could avoid this simply by not using the iframes. You could just as well put the header on each page. The pages will load fast (images are cached) and it's much easier both for you and for users. Users may want to bookmark pages or send the link to a specific page to someone. Will they get the right page? Most will probably not, especially since the iframe isn't visible so even those who know how to do it won't realize they are up against frames.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Nov 22 2006, 08:12 AM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



That script doesn't do what (I think) you want BTW. It just redirects to the index page.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Nov 22 2006, 08:28 AM
Post #5


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Here you have one. I don't know how it fares in older browsers.
http://allmyfaqs.net/faq.pl?Keep_documents..._their_frameset
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Frederiek
post Nov 22 2006, 12:42 PM
Post #6


Programming Fanatic
********

Group: Members
Posts: 5,146
Joined: 23-August 06
From: Europe
Member No.: 9



Here's another: http://www.quirksmode.org/js/framecustom.html, by PPK
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Nov 22 2006, 01:26 PM
Post #7


.
********

Group: WDG Moderators
Posts: 9,650
Joined: 10-August 06
Member No.: 7



QUOTE(pandy @ Nov 22 2006, 02:28 PM) *

Here you have one. I don't know how it fares in older browsers.
http://allmyfaqs.net/faq.pl?Keep_documents..._their_frameset


That script cannot work by itself. First it needs something that calls the function, but even then it seems it simply redirects to something like

CODE
http://www.myownsite.com/?http://www.myownsite.com/original_page.html


so you also need a script in the frameset file that rewrites its FRAME SRC to the query string value.

I experimented with such a frameset javascript a while ago, but couldn't make it work unless I used "document.write" like in Quirksmode's example, but alas I believe Quirksmode uses invalid HTML (IIRC you can't use the SCRIPT element outside BODY or HEAD, and to use document.write to write FRAMESET or FRAME elements you must do exactly that). IMO it's much better to use a server-side script for these things.

Also keep in mind that neither http://allmyfaqs.net/faq.pl?Keep_documents..._their_frameset nor http://www.quirksmode.org/js/framecustom.html check what the query string contains, so a malicious user may do something like this http://www.konsumentverket.se/mallar/Frame...CategoryId=1604 and possibly fool someone (in the link above The Swedish Consumer Agency frames an arbitrary page).
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Nov 23 2006, 01:49 PM
Post #8


.
********

Group: WDG Moderators
Posts: 9,650
Joined: 10-August 06
Member No.: 7



QUOTE(Christian J @ Nov 22 2006, 07:26 PM) *

I experimented with such a frameset javascript a while ago, but couldn't make it work unless I used "document.write" like in Quirksmode's example


After looking at my old experiments it seems you can use window.onload from a script in the frameset's HEAD section, and change the location.href of a FRAME SRC depending on the frameset's query string (at least in newer Windows browsers). The main problem seems to be that IE and Opera mess up the browser history: in IE6 the Back button takes you to the frameset default pages, while Opera produces two blank frames.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 18th April 2024 - 04:21 AM