Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 31st, 2005, 8:07 PM   #1
Lance
Programmer
 
Lance's Avatar
 
Join Date: Oct 2004
Location: Chicago, IL USA
Posts: 74
Rep Power: 4 Lance is on a distinguished road
Send a message via AIM to Lance
Built-in functions?

So I'm designing a little site to learn JavaScript and DHTML, and it's going to be a mini Window Manager. Yea, I'm kinda' crazy. Anyways...

http://grog.mine.nu/~lance

I'm trying to make the top 'taskbar' focus onto a window. If they overlap, I want the taskbar to change focus to the clicked title.

But I get this...

Error: document.getElementById("windowone").focus is not a function

focus() is supposed to be a built-in function of every element, according to the W3C DOM Level 1 Specifications.

What am I doing wrong...?
__________________
/* LANCE */
C++;  /* this makes C bigger but returns the old value */
char *site = "slackwise.net",
     *home = "lance.slackwise.net",
     *pics = "flickr.com/photos/slackwise";
Lance is offline   Reply With Quote
Old Aug 31st, 2005, 8:32 PM   #2
Eryk
Programmer
 
Join Date: Jul 2005
Posts: 62
Rep Power: 4 Eryk is on a distinguished road
Those are java specifications, not javascript.

You can only use focus() on form elements, except in IE, which allows anything.
What do you need the focus on it for? (Just wondering)
Eryk is offline   Reply With Quote
Old Aug 31st, 2005, 8:46 PM   #3
Lance
Programmer
 
Lance's Avatar
 
Join Date: Oct 2004
Location: Chicago, IL USA
Posts: 74
Rep Power: 4 Lance is on a distinguished road
Send a message via AIM to Lance
GAH! But I swear I was reading their page on JavaScript from w3.org/DOM. Then clicked the "Specifications" link. :/

Anyways, that sucks. I'll never get my focus working. It means I'll have to code it myself... and I have no clue how.

And by the way, I'm making a Window Manager. The top is a taskbar, the bottom DIV's are 'windows'. You get the picture.
__________________
/* LANCE */
C++;  /* this makes C bigger but returns the old value */
char *site = "slackwise.net",
     *home = "lance.slackwise.net",
     *pics = "flickr.com/photos/slackwise";
Lance is offline   Reply With Quote
Old Aug 31st, 2005, 8:56 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
What exactly do you want to do when you call the focus() function? Bring the window forward?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Aug 31st, 2005, 8:58 PM   #5
Eryk
Programmer
 
Join Date: Jul 2005
Posts: 62
Rep Power: 4 Eryk is on a distinguished road
The focus function wouldn't exactly work for that. It works a bit differently.

The best way to go at it is like you said, to make a custom function.
It would just have to change the Z-index if I remember correctly.
Eryk is offline   Reply With Quote
Old Aug 31st, 2005, 9:02 PM   #6
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
That's exactly what I was thinking.
// assuming you have an array of windows called "windows"

function focus (element)
{
	element = document.getElementById(element);
	
	i = 0;
	for (i = 1; i <= windows.length; i++)
	{
		windows.style.z-index = i;
	}
	
	element.style.z-index = i;
}
Not tested, but it should work with a couple of inevitable bug fixes.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Aug 31st, 2005, 9:43 PM   #7
Lance
Programmer
 
Lance's Avatar
 
Join Date: Oct 2004
Location: Chicago, IL USA
Posts: 74
Rep Power: 4 Lance is on a distinguished road
Send a message via AIM to Lance
z-index? I'll check it out.

And I'll check your code out later, Ooble. If I can't figure it out myself. You're half ruining the fun of coding this. You're making it lose hack value.

But thanks for your help.
__________________
/* LANCE */
C++;  /* this makes C bigger but returns the old value */
char *site = "slackwise.net",
     *home = "lance.slackwise.net",
     *pics = "flickr.com/photos/slackwise";
Lance is offline   Reply With Quote
Old Aug 31st, 2005, 9:49 PM   #8
Eryk
Programmer
 
Join Date: Jul 2005
Posts: 62
Rep Power: 4 Eryk is on a distinguished road
You could always find another way of coding it. I konw it's annoying to do so, but meh.

Also, is the drag and drop yours? Because it looks familiar.
Eryk is offline   Reply With Quote
Old Aug 31st, 2005, 11:40 PM   #9
Lance
Programmer
 
Lance's Avatar
 
Join Date: Oct 2004
Location: Chicago, IL USA
Posts: 74
Rep Power: 4 Lance is on a distinguished road
Send a message via AIM to Lance
var zindex = 5;
function raise(element)
{
	document.getElementById(element).style.zIndex = zindex;
	zindex++;
}

Yep. I did it. Simple.

Ooble: You made it more complex than it needed to be. :/

Eryk: They were actually taken from a tutorial. --> http://www.brainjar.com/dhtml/drag/

Rest of the code is mine.
__________________
/* LANCE */
C++;  /* this makes C bigger but returns the old value */
char *site = "slackwise.net",
     *home = "lance.slackwise.net",
     *pics = "flickr.com/photos/slackwise";
Lance is offline   Reply With Quote
Old Sep 1st, 2005, 12:10 AM   #10
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
The page linked was a w3c Java implementation of the JavaScript DOM (document object module).... so it's kinda both Java and JavaScript.
__________________

tempest is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:14 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC