homepage Welcome to WebmasterWorld Guest from 50.19.169.37
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
How To Prevent Pages From Opening Without Frames
Is this possible in a normal html website?
HolyDoom Witch




msg:4319604
 3:28 pm on May 30, 2011 (gmt 0)

I was unable to understand the thread [webmasterworld.com...] and probably unsuccessful too, to implement a code/solution, that would prevent pages opening like a whole site, instead of their designated frames, like from a search engine.

Let us now proceed to know the reasons of failure. May be someone could paste the code right here, and instruct where I have to paste, and what I have to upload.

We shall now close this thread only when this problem solves.

Thanks

HDW

[edited by: tedster at 10:10 pm (utc) on May 30, 2011]
[edit reason] fixed the link [/edit]

 

tedster




msg:4319825
 2:42 am on May 31, 2011 (gmt 0)

Your last question in the previous thread was:

passpage = document.URL
if (top.location == self.location)
location.replace("master.html?" + passpage)

In the above code, I insert my page name after the question mark.

No, you don't insert your page name anywhere at all. "passpage" is a variable that the first line of the script defines for you. It automatically carries the name of your child page to the script in the parent frameset page.

I find that people often try to make this more complicated than it is. Don't play with it in any way, don't add your own this or that into the script - just follow the instructions in that thread completely by rote.

FORCE MANY PAGES INTO FRAMES [webmasterworld.com]
with one simple script

HolyDoom Witch




msg:4320173
 8:07 pm on May 31, 2011 (gmt 0)

All right. First with what I was trying to do. Page name you said. Look what is written here.

You can add ANY page's name to the end of a URL [after a "?"]

This is the confusion.

Now can you tell me what exactly I have to do with the above script? I think you haven't clearly told exactly WHERE to paste it. I read it once again. And is it, that I have to paste it in every page, AND make a master.html as well?

Thanks
HDW

tedster




msg:4320228
 10:11 pm on May 31, 2011 (gmt 0)

You paste that javascript in the <head> section of every html page that should appear within the frameset and not on its own.

I should mention, since you are new to coding, that you include the script within a <script></script> element, all within the <head></head> element:

<script>
passpage = document.URL
if (top.location == self.location)
location.replace("master.html?" + passpage)
</script>


And yes, you also need to build one master.html page, as the original post describes. Be sure to adjust the dummy code to mirror the exact proportions and number of frames that your original frameset uses.

HolyDoom Witch




msg:4320649
 5:41 pm on Jun 1, 2011 (gmt 0)

Now here is what I am doing Ted. I am pasting this script into a simple HTML document:
<head>
blah blah blah...

<script>
passpage = document.URL
if (top.location == self.location)
location.replace("master.html?" + passpage)
</script>

<head>

And here is what I have pasted in the master.html document:

<head>
blah blah blah...

<script type="text/javascript">
if (top==self) { location.replace("master.html?" + location.href) }
</script>

<head>

I hope I haven't reversed the roles, first of all. And if not, then there seems to be an infinite loop, that would keep loading the page, but not show any contents. Even the address bar has an infinitely long address.

Has it got anything to do with what you have told in your scripts page, like you have said there in THE BACK BUTTON section, something about a loop there? May be this is another of a similar thing?

And yes, the script FIRST MENTIONED on the scripts page under this "FORCE MANY PAGES..." section, is a little different than what is given here. Probably the ones here are updated versions that you later explain in the BACK BUTTON section.

Thanks

tedster




msg:4320709
 7:54 pm on Jun 1, 2011 (gmt 0)

The page master.html is a DYNAMIC COPY of your existing frameset page. Here's the code as given on the other thread:

<html>
<head>
<title>Master Frameset</title>
</head>

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

origURL = parent.document.URL
contentURL = origURL.substring(origURL.indexOf('?')+1, origURL.length)

document.write('<frameset cols="20%,80%"><frame src="leftnav.html" name="nav"><frame src=\"' + contentURL + '\" name="content"><\/frameset>')

</script>
</html>


The document.write() section needs your adjustment to fit the exact configuration of your original frameset page.

The code I offered assumes a frameset that has just two frames, one at 20% for leftnav.html and the other frame at 80% width that gets filled in with the URL where the visitor originally landed. That frame source gets supplied by the javascript.

If you are new to HTML code, you may need to research the frameset tags to get it all sorted for your particular website. You might have 3 or more individual frames and not 2, you might be using fixed pixel widths instead of percentages, etc.

HolyDoom Witch




msg:4323976
 12:18 pm on Jun 9, 2011 (gmt 0)

My frame "Size" are:

Left Frame:
Width = 1 Relative
Row height = 1 Relative

Upper Frame:
Column Width = 1 Relative
Height = 16 Percent

Right Bottom:
Width = 81 Percent
Row height = 1 Relative

How do I insert these values, instead of your "20%,80%"?

Thanks
HDW

tedster




msg:4324063
 3:05 pm on Jun 9, 2011 (gmt 0)

I do not understand what you mean by "1 relative" and the like - that's not html for a frameset layout.

Please paste your original frameset mark-up into a post. The document.write content is going to mirror that.

londrum




msg:4324068
 3:10 pm on Jun 9, 2011 (gmt 0)

here is another way of doing it which might be easier. just paste it in the head

<script type="text/javascript">
if (top == self) {
var parent_url = "main_frameset.html";
var orphan_url = self.location.href;
var reframe_url = parent_url + "?" + orphan_url;
location.href = reframe_url;
}
parent.navigation_frame.location.href="navigation_frame.html";
</script>

change main_framset.html to whatever your main frameset page is. and change navigation_frame to whatever the frame name(id) is that is missing, and navigation_frame.html to whatever that filename is.

When someone visits the page directly, it should load in the main framset around it. the only problem is you will end up with an ugly URL, so you should make sure its got a canonical tag.

HolyDoom Witch




msg:4326442
 4:32 pm on Jun 15, 2011 (gmt 0)

change main_framset.html to whatever your main frameset page is.
I changed this part to "index.html".

and change navigation_frame to whatever the frame name(id) is that is missing,
I had to pay more attention to know if there is a "frame name", and this I changed to "rbottom".
There are three frames:
-----------------------------rtop----------------------------------
------rbottom1 -------------------- r b o t t o m -------------------------

rtop (Links)
rbottom1 (More links. Strange it is on left side yet known as right bottom 1.)
rbottom (This is where I want all the pages to open.)

and navigation_frame.html to whatever that filename is.
I changed this to welcome.html, a file that I want to open in rbottom. When I test this file in the browser, after saving the document index.html after pasting and modifying the code, this file welcome.html, does not open in a complete frame, like, as from the links in rtop and rbottom1. I hope this should happen.
When I paste the same code in the welcome.html, then I get 4 pages of same hard disk URL in the address bar. I pasted in Word to see. Content in Opera 11.1 is not visible. IE8 also shows as one page instead of opening the index.html, with the welcom.html on rbottom, except for the warning about blocked content, that I "Allow...". Both browsers are in a kind of infinite loop as indicated by the flickering of certain parts of the browsers, and I think are generating more of the URL in the address bar. Same was happening with the code administrator here is trying to provide.
Please remember, that in the first testing, I changed the "navigation_frame" to welcome.html IN welcome.html.
Then I changed "navigation_frame" to welcome.html in index.html also, the main frame document, but off course this is not to be done.

When someone visits the page directly, it should load in the main framset around it. the only problem is you will end up with an ugly URL, so you should make sure its got a canonical tag.
Now since you have taken it upon yourself to walk me through this mess, you also explain me what a "canonical tag" is.

Please study carefully and let me know whatever the hell I am missing.

Thanks.

HDW

tedster




msg:4326732
 3:06 am on Jun 16, 2011 (gmt 0)

You are making this much harder than it needs to be, by improvising and reading things into the instructions that are not there. I cannot help you further unless you answer my earlier requests.

Please paste your original frameset mark-up into a post.

tangor




msg:4326774
 5:36 am on Jun 16, 2011 (gmt 0)

Not going to get too involved in this, but if doing HTML FRAMESETS, why the heck get javascript involved at all? A simple three section: (Left, top right head, bottom right main). Beauty is it runs in javascript disabled browsers... If you want to FORCE your frameset, you'll have to look for js code "frame busters" to install each page. Then again, that will fail with js disabled browsers.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<HTML>

<!-- frames -->
<frameset cols="144,*" frameborder="0" border="0" framespacing="0">
<frame name="menu" src="menu.html" marginwidth="5" marginheight="5" scrolling="no" frameborder="no" framespacing="0">
<frameset rows="64,*">
<frame name="header" src="header.html" marginwidth="0" marginheight="0" scrolling="No" frameborder="no" noresize framespacing="0">
<frame name="splash" src="splash.html" marginwidth="20" marginheight="10" scrolling="Auto" frameborder="no" framespacing="0">
</frameset>
<noframes>
<body bgcolor="#F0F8FF">

Whatever desired for noframes

</body>
</noframes>
</frameset>
</html>

HolyDoom Witch




msg:4327740
 11:57 am on Jun 18, 2011 (gmt 0)

H! Tangor

When I had started the previous thread, I had hoped for a solution that would be a language-free, HTML solution. But when the admin here offered me the Java script, I got a little disappointed, but thought that that may be the only solution- to have one or other language that is. I too thought about PCs without that particular language, but thought that may be there is no HTML solution. But I am very happy to see your script! May be if this works smoothly, then the admin would have it himself to offer here on this site on the scripts page. Let me try it.

Thanks

HolyDoom Witch




msg:4327939
 8:27 am on Jun 19, 2011 (gmt 0)

But first what Tedster asked for. Here it is:

<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 12.0">
<meta name="keywords" content="www.#*$!#*$!#*$!#*$!x.org, #*$!#*$!#*$!">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>#*$!#*$!#*$!#*$!#*$!#*$!#*$!#*$!#*$!#*$!#*$!#*$!#*$!#*$!#*$!#*$!x</title>
</head>

<frameset cols="*" framespacing="0" border="0" frameborder="0">
<frameset rows="16%,*">
<frame name="rtop" target="rbottom" src="index1.html" scrolling="auto" noresize="noresize">
<frameset cols="*,81%">
<frame name="rbottom1" src="index2.html" target="rbottom" scrolling="auto">
<frame name="rbottom" src="welcome.html" target="_self" scrolling="auto">
</frameset>
</frameset>
<noframes>
<body>


</body>
</noframes>
</frameset>

</html>

londrum




msg:4327945
 9:19 am on Jun 19, 2011 (gmt 0)

thats not going to stop pages opening without their frames though. wasn't that the question?

you cant do that with HTML alone, its impossible. if you want to check that pages are inside their correct frame, and then put them in if they are not, then you need something else, like javascript.

tedster




msg:4328010
 6:06 pm on Jun 19, 2011 (gmt 0)

Thank you for posting your frameset code. First, a preliminary comment. The target attribute is not part of the <frame> element. Instead it can be an attribute of any link within one of the framed URLs. For that reason, I have dropped the attribute "target" from your original source code.

What happens in this script is that the document.write() method actually writes your frameset configuration into the page dynamically. But instead of being a literal, verbatim copy, it uses the variable named "contentURL" as the src attribute of the main frame - marked in red below. This allows the script to declare the visitor's original landing page, whatever it was, as the course of that particular frame.

In your case, I'm assuming that the frame "rbottom" is where the content URL should load - it's marked in bold red below.

-----
<html>
<head>
<title>Master Frameset</title>
</head>

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

origURL = parent.document.URL
contentURL = origURL.substring(origURL.indexOf('?')+1, origURL.length)

document.write('<frameset cols="*" framespacing="0" border="0" frameborder="0">
<frameset rows="16%,*">
<frame name="rtop" src="index1.html" scrolling="auto" noresize="noresize">
<frameset cols="*,81%">
<frame name="rbottom1" src="index2.html" scrolling="auto">
<frame name="rbottom" src=
\"' + contentURL + '\" scrolling="auto">
</frameset>
</frameset>
<noframes>
<body>
</body>
</noframes>
</frameset>'
</script>
</html>

-----

You can sometimes have problems when you include line breaks within the document.write() method, and for that reason, I recommend removing those line breaks in your final source code:

<html>
<head>
<title>Master Frameset</title>
</head>

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

origURL = parent.document.URL
contentURL = origURL.substring(origURL.indexOf('?')+1, origURL.length)

document.write('<frameset cols="*" framespacing="0" border="0" frameborder="0"><frameset rows="16%,*"><frame name="rtop" src="index1.html" scrolling="auto" noresize="noresize"><frameset cols="*,81%"><frame name="rbottom1" src="index2.html" scrolling="auto"><frame name="rbottom" src=\"' + contentURL + '\" scrolling="auto"></frameset></frameset><noframes><body>
</body></noframes></frameset>')

</script>
</html>

[edited by: tedster at 4:37 am (utc) on Jun 28, 2011]

tedster




msg:4331908
 4:35 am on Jun 28, 2011 (gmt 0)

Have you got it working now?

HolyDoom Witch




msg:4332451
 9:33 am on Jun 29, 2011 (gmt 0)

WITHOUT any changes, no.

The only change I did was...

Hey Tedster,

How do you bring the highlight box? Let me post the codes that I pasted in both documents:
index.html (the 3-frameset document)
about.html

And please excuse my slow pace. I hope you don't close threads before 4-5 months. I'll try to go to any length to solve the problem.

Thanks

tedster




msg:4332621
 5:17 pm on Jun 29, 2011 (gmt 0)

Threads here lock on an automated basis - but only after several months of inactivity.

HolyDoom Witch




msg:4333827
 8:07 pm on Jul 1, 2011 (gmt 0)

And what about the highlight box I asked for?

tedster




msg:4333875
 9:42 pm on Jul 1, 2011 (gmt 0)

I know I'm being blunt, but this forum isn't a free coding service. In general, the effective way to ask for help is to say:

1. I want to write code that does X
2. I've tried Y and it fails in this way
3. Can someone see where I've gone wrong?

Other than showing that kind of participation and "sharing the burden", you're asking too much of other members.

For example, you haven't even explained what you mean by a "highlight box" - so even step #1 above is missing.

TenTonJim




msg:4334356
 5:36 am on Jul 3, 2011 (gmt 0)

LoL I'm sorry... I haven't been here in about 10 yrs but that was pretty classic. Sounds like a typical client request :~)

HolyDoom Witch




msg:4334967
 5:14 am on Jul 5, 2011 (gmt 0)

Oh c'mon Tedster, it was just the light-violet box you bring to post codes on your own site! :D

It was just that I wanted to make it neat and clean in less space.

HolyDoom Witch




msg:4336241
 9:53 am on Jul 7, 2011 (gmt 0)

Let's cut the box. Here are the codes:

INDEX.HTML
<script language="JavaScript" type="text/javascript">

origURL = parent.document.URL
contentURL = origURL.substring(origURL.indexOf('?')+1, origURL.length)

document.write('<frameset cols="*" framespacing="0" border="0" frameborder="0"><frameset rows="80%,*"><frame name="rtop" src="index1.html" scrolling="auto" noresize="noresize"><frameset cols="*,80%"><frame name="rbottom1" src="" scrolling="auto"><frame name="rbottom" src=\"' + contentURL + '\" scrolling="auto"></frameset></frameset><noframes><body>
</body></noframes></frameset>')

</script>

____________________________________________________________

ABOUT.HTML
<script language="JavaScript" type="text/javascript">

origURL = parent.document.URL
contentURL = origURL.substring(origURL.indexOf('?')+1, origURL.length)

document.write('<frameset cols="*" framespacing="0" border="0" frameborder="0"><frameset rows="80%,*"><frame name="rtop" src="index1.html" scrolling="auto" noresize="noresize"><frameset cols="*,80%"><frame name="rbottom1" src="about.html" scrolling="auto"><frame name="rbottom" src=\"' + contentURL + '\" scrolling="auto"></frameset></frameset><noframes><body>
</body></noframes></frameset>')

</script>

Let's take a direct approach. If you tell me exactly which values I have to change in the above script, then it becomes a lot easier to reach the correct script. Here are the schematics for my site that you may need:

-----------------------------rtop(links; index1.html)--------------
rbottom1 (links; index2.html) ------------- r b o t t o m (all content eg: about.html)

Thanks

tedster




msg:4336516
 6:04 pm on Jul 7, 2011 (gmt 0)

Scripts do not belong in your original index.html page. They belong in a new page (one that I named master.html).

ABOUT.HTML (and any other URL that belongs in the rbottom frame)
note: the only JavaScript is BETWEEN <head> and </head>
<html>
<head>
<script language="JavaScript" type="text/javascript">

passpage = document.URL
if (top.location == self.location)
top.location.href="master.html?" + passpage

</script>
</head>
<body>
[whatever you need]
</body>
</html>


MASTER.HTML
note: the only JavaScript is AFTER the </head> tag
<html>
<head>
<meta name="robots" content="noindex">
</head>

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

origURL = parent.document.URL
contentURL = origURL.substring(origURL.indexOf('?')+1, origURL.length)

document.write('<frameset cols="*" framespacing="0" border="0" frameborder="0"><frameset rows="16%,*"><frame name="rtop" src="index1.html" scrolling="auto" noresize="noresize"><frameset cols="*,81%"><frame name="rbottom1" src="index2.html" scrolling="auto"><frame name="rbottom" src=\"' + contentURL + '\" scrolling="auto"></frameset></frameset><noframes><body>
</body></noframes></frameset>')

</script>
</html>

HolyDoom Witch




msg:4336734
 2:03 am on Jul 8, 2011 (gmt 0)

No way. The script won't work.

Either I am wrong somewhere- even now. Or the script won't work in such a scenario. One thing that you might want to do Tedster is take a copy of Expression Web 4, design the same style web site with one line of text, and try if your script works at your place. If yes, then we can compare the results, and probably easily point out my mistake. I can also email you my three documents, that you can test yourself. (Or may be the script needs some change.)

On the other hand, the HTML script posted by Tangor does give a hope. When you paste it in a page, the Expression Web document suddenly turns into a frameset document with all the three frames visible, though the pages still missing. May be I'll need to work on the parameters more. (I could do this quickly if he could tell me what do all the parameters stand for.)

So I suggest you test your script at your place in my conditions, which somehow I feel sure, it won't work. And then if you think you are going to need a new script for frame forcing issue, then let us work, till a few posts, on this HTML one.

Meanwhile, I, till the end have felt that somehow, your site is very useful, even if only one person replies to the queries promptly (like, you know, on some big sites where other users reply by the minute).

Sorry for causing the inconvenience. But I hope that if I was right in implementing the scripts, then you would make some or other necessary change that would finally work in every situation. Or a new script for a different situation.

Thanks to everyone.

Leosghost




msg:4336735
 2:20 am on Jul 8, 2011 (gmt 0)

Using Expression Web ( anything ) is about as wrong as you can get ..hoping that someone will sort out the tag soup that it and its ilk generate for free on a pro webmaster forum is really not "getting" what this place is about..

tedster ( who is being phenomenally patient here ..even for tedster ;-) has given you the solution .."your conditions"=using Expression web= handicapping yourself from the start..

you'll learn so much more by junking it ..and using a text editor ..editpad (or even homesite if you can find it ) or aracnophilia.

or asking in the expression web support forums ( presuming they have such things ) ..

HolyDoom Witch




msg:4337341
 9:57 am on Jul 9, 2011 (gmt 0)

Actually I don't even know if there is a "serious" problem in Expression Web. (Not like it doesn't give any problems.) So thanks for telling me which editor I should use.

If I find the script working in these editors, I'll come back.

As far as the free/pro nature of the forums is concerned, I don't question your professionalism. Please assist me only as much as your extra time allows. Having a solution to this issue is a good choice, but surely cannot be a pressing issue in any situation; website does work after all, without it.

Of course, thanks for your patience, and which seemed very professional.

Thanks

tedster




msg:4337412
 4:13 pm on Jul 9, 2011 (gmt 0)

thanks for telling me which editor I should use

The key is that you should be able to get "hands-on" with the code and not depend on any WYSIWYG representations of how the final page will look and perform. For that information, only testing in a browser will show you what you need to see.

I'm not saying that something about the code I offered might not fail in your particular situation. For instance, I may have made assumptions about your existing mark-up (of the "everyone knows" variety) that night not be the case.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved