/    Sign up×
Community /Pin to ProfileBookmark

Focus Problems

This is a non-example based request for basic info about the focus() method. For the sake of my request, the mess of my entire .js file is included at the bottom of this post.

My site is an upper 50% flash nav, lower 50% html scrolling div based “frames” feel layout. My content change-up is based on shifting one div to style.display = ‘none’; and another div to style.display = ‘block’;

Anyhow, I’ve had to jump through hoops to get focus to remain on the lower part of the site. The problem is most noticeable in reference to forms.

Currently, I have it setup so that when you mouseover the lower part, it brings focus to the lower area. I’m sensing that it doesn’t always work because now and then I have to double-click to enter text into a form field.

This may be in part due to the fact that upon entry it loses focus or that there is another so.write area for embedded audio which is user operated (play different track, for example).

I’m hoping to simply better understand what angle to take on this in terms of simple and efficient code. I’ve never had a problem like this, so I’m all eyes.
Suggestions?

Here’s the mess (can’t fit it all, so only the onmouseover focus part) …

[CODE]var reset;
var input;
var form;
var front = ‘true’;
function ResetInput() {
if (reset == ‘true’) input.value = input.defaultValue;
form = ‘inactive’;
reset = ‘false’;
}
var mouse;
function BlockMouse() {
content.onselectstart = new Function(‘return false;’);
content.style.MozUserSelect = ‘none’;
content.ondragstart = new Function(‘return false;’);
content.oncontextmenu = new Function(“return false;”);
if (document.navigation) {
content.onmouseover = new Function(“if (front == ‘true’ && active != ‘true’) content.focus();
active = ‘true’;”);
content.onmousedown = new Function(“mouse = ‘down’;”);
content.onmouseup = new Function(“ResetInput();
mouse = ‘up’;”);
content.onscroll = new Function(“if (hidden != ‘true’) GetNews(‘reset’);
else hidden = ‘false’;”);
}
}
function ClearMouse() {
content.onselectstart = new Function(‘return true;’);
content.style.MozUserSelect = ‘text’;
}
var focals;
function HideFocus(tag) {
focals = document.getElementsByTagName(tag);
if (!focals) return;
for (var x = 0;
x != focals.length;
x++) {
focals[x].onfocus = function() {
this.hidefocus = true;
};
}
}
function InputStatus() {
input.onfocus = new Function(“ClearMouse();
this.value = ”;”);
input.onblur = new Function(“BlockMouse();
if (form != ‘active’) this.value = this.defaultValue;”);
}
var subscribe;
function ButtonDown() {
subscribe.style.borderColor = ‘#ddaa33’;
subscribe.style.background = ‘#ddaa33’;
subscribe.style.color = ‘#000000’;
}
function ButtonUp() {
subscribe.style.borderColor = ”;
subscribe.style.background = ”;
subscribe.style.color = ”;
}
var image;
function ImageStatus() {
image.onmouseover = new Function(“if (mouse == ‘down’ && form == ‘active’) ButtonDown();
reset = ‘false’;”);
image.onmousedown = new Function(“ButtonDown();
form = ‘active’;”);
image.onmouseup = new Function(“ButtonUp();”);
image.onmouseout = new Function(“ButtonUp();
if (mouse == ‘down’) reset = ‘true’;”);
}[/CODE]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @robindean spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...