PDA

View Full Version : Forcing in focus



cyberdreamer
09-22-2008, 09:48 PM
I am so sorry if i have posted in the wrong place.

I am pretty much a noob but am willing to learn, and hopefully in time help others.

I have 3 frames on my webpage. I am trying to force the focus to the heading tag <h1> in the frame called hmcontent.
I want to set it to a heading, <h1> tag. the heading is in the frame called hmcontent defined in the frameset in index.html

Sorry its a bit complicated. To be honest i am not sure its possible.
Please prove me wrong. - Thanks in advance.

Moshambi
09-22-2008, 10:15 PM
do you have any code for this?

cyberdreamer
09-25-2008, 08:06 PM
Hi Moshambi,
As I said I am a complete noob, I am planning to make my site accessable for blind users using a screen reader. (It basically needs the main content page to always start at the top (and have focus) as the screen reader needs to start reading from there. (there will be very little in the way of graphics for obvious reasons although I could add an alt image tag).

Here is the code I have so far (It is very very basic I havent added any menus or links yet.) I am learning as I go.

Here is the source for index.html

<HTML>
<HEAD>
<TITLE>A basic frameset document (test for my wesite)</TITLE>
</HEAD>
<FRAMESET cols="20%, 80%">
<FRAMESET rows="100, 200">
<FRAME src="logo.jpg">
<FRAME src="Frame1.html">
</FRAMESET>
<FRAME src="hmcontent.html">


<NOFRAMES>
<P>This frameset document contains:
<UL>
<LI><IMG src="logo.jpg" alt="My Logo">
<LI><A href="Frame1.html">This is my where my menu is (When I figure out how to do it)</A>
<LI><A href="hmcontent.html"> My Main content</A>
</UL>
</NOFRAMES>
</FRAMESET>
</HTML>

Here is the source for hmcontent.html

<HTML>
<HEAD>
<BODY>
<H1> This is where I want my first Heading to be.</h1>
<BR>

<h2> This is where my first paragraph title will be </h2>
<P>
Here is where all the other text will be - this is where I will be putting my main content.
This will change when I click on the menu. </P>

<h2> This is where my second paragraph title will be </h2>

<p> Here is more stuff </p> (There is probably and easier way to do this but I am only learning so
it is a case of not running before I can walk).

<h2> This is where I want my third Heading will be </h2>
<p> Here is where my third paragraph will be </p>
(basically it will be an update page of whats new on the site when I get it up and running).
</BODY>
</HEAD>
</HTML>


Hope You can help
Thanks again - Cyberdreamer

jscheuer1
09-27-2008, 02:24 PM
Well, you cannot control the focus in your documents without some form of client side script, generally javascript. Browsers will otherwise just do whatever is their default, and this varies slightly in some browsers, but even more so in a frameset depending upon which page within it finishes loading last, and if any of these have forms that require focus.

And, you cannot focus on an H1 element. Only windows, frames, and form inputs can reliably receive focus via javascript (some - only some - browsers will allow links to do so as well). So, about the best that you can do is to focus on the frame containing the page with the H1 element on it. You could also add something to make it blink or highlight or something like that, but that is not focus, though it will draw the user's attention.

Now, how to set focus? This should probably be refined to be more specific, but in about the simplest terms you can:


<HTML>
<HEAD>
<TITLE>A basic frameset document (test for my wesite)</TITLE>
</HEAD>
<FRAMESET cols="20%, 80%" onload = "window.frames['main'].focus();">
<FRAMESET rows="100, 200">
<FRAME src="logo.jpg">
<FRAME src="Frame1.html">
</FRAMESET>
<FRAME name="main" src="hmcontent.html">


<NOFRAMES>
<P>This frameset document contains:
<UL>
<LI><IMG src="logo.jpg" alt="My Logo">
<LI><A href="Frame1.html">This is my where my menu is (When I figure out how to do it)</A>
<LI><A href="hmcontent.html"> My Main content</A>
</UL>
</NOFRAMES>
</FRAMESET>
</HTML>

cyberdreamer
09-27-2008, 09:08 PM
Many thanks jscheuer1 :- I will try and incorperate your suggestion into my site.
I must say I am most impressed by the fast response and friendly welcome I have recieved in the forums. Hopefully in time I can pass on my knowledge too (although there isnt much knowledge at the moment).

Anyway - Once again thanks !!

jscheuer1
09-27-2008, 11:18 PM
I just noticed a critical typo in my code example that I have also just fixed in the original, I left out a quotation mark (red) in the below:


onload = "window.frames['main'].focus();"