Where's the Window()

M

Martin Rinehart

I've got most of the components of a robust color chooser but I'm
having trouble pulling them together.

What I want is to have a ready-to-use but not visible pop-up object
created when the application is loaded. On a click on a color button,
this thing should pop up as a modal dialog. It should hide when the
user chooses OK, Cancel or clicks the window closing button.

"window.open(...)" opens a window, which is not what I want when the
application loads. My development platform, Opera on Konqueror,
doesn't support "new Window(...)". This was dead simple in Java (and I
may still be thinking in Java).

There's a Java example of where I'm going at

http://www.MartinRinehart.com/examples/color-chooser.html

(This is a slug in Firefox on XP Pro - use any other browser or FF
with XP Home or any earlier Windows. I've no clue why.)

The JavaScript version will be better.
 
E

Erwin Moller

Martin Rinehart schreef:
I've got most of the components of a robust color chooser but I'm
having trouble pulling them together.

What I want is to have a ready-to-use but not visible pop-up object
created when the application is loaded. On a click on a color button,
this thing should pop up as a modal dialog. It should hide when the
user chooses OK, Cancel or clicks the window closing button.

"window.open(...)" opens a window, which is not what I want when the
application loads. My development platform, Opera on Konqueror,
doesn't support "new Window(...)". This was dead simple in Java (and I
may still be thinking in Java).

There's a Java example of where I'm going at

http://www.MartinRinehart.com/examples/color-chooser.html

(This is a slug in Firefox on XP Pro - use any other browser or FF
with XP Home or any earlier Windows. I've no clue why.)

The JavaScript version will be better.

What is your question?
How to open a new window when somebody pushes the button?

To do that you'll need window.open() not new Window().

Regards,
Erwin Moller

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
D

Daniel Orner

Martin said:
I've got most of the components of a robust color chooser but I'm
having trouble pulling them together.

What I want is to have a ready-to-use but not visible pop-up object
created when the application is loaded. On a click on a color button,
this thing should pop up as a modal dialog. It should hide when the
user chooses OK, Cancel or clicks the window closing button.

"window.open(...)" opens a window, which is not what I want when the
application loads. My development platform, Opera on Konqueror,
doesn't support "new Window(...)". This was dead simple in Java (and I
may still be thinking in Java).

There's a Java example of where I'm going at

http://www.MartinRinehart.com/examples/color-chooser.html

(This is a slug in Firefox on XP Pro - use any other browser or FF
with XP Home or any earlier Windows. I've no clue why.)

The JavaScript version will be better.

You'll probably want the content in a div rather than a separate
window. You can hide the div and position/show it when needed. Browsers
generally don't have the idea of "modal" windows in any case, so you'll
need to go this route.
 
M

Martin Rinehart

Daniel said:
You'll probably want the content in a div rather than a separate
window. You can hide the div and position/show it when needed. Browsers
generally don't have the idea of "modal" windows in any case, so you'll
need to go this route.

The color chooser in its own window is quite nice as you can drag it
around (inevitable: it pops up over something you want to look at). Do
I need to write a draggable div widget?
 
M

Martin Rinehart

Erwin said:
What is your question?
How to open a new window when somebody pushes the button?

To do that you'll need window.open() not new Window().

That insists on opening the window. I'd like to construct the window
before it's visible, then show/hide it based on the users' clicks.
 
M

Martin Rinehart

It just gets odder and odder.

function popup() { // called on button click
var cc = window.open( ... ) // window pops up
alert( cc ); // alert appears after window is closed. reports
"object Window"
alert( cc ); // reports "object Object"
}
 
E

Erwin Moller

Martin Rinehart schreef:
That insists on opening the window. I'd like to construct the window
before it's visible, then show/hide it based on the users' clicks.

Any reason for that?
Anyway, if you must: follow Daniels advise and make it a div.
And yes, you must take care of the dragging of that div-'window' then.

Erwin Moller


--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
E

Erwin Moller

Martin Rinehart schreef:
It just gets odder and odder.

function popup() { // called on button click
var cc = window.open( ... ) // window pops up
alert( cc ); // alert appears after window is closed. reports
"object Window"

I doubt that...
I never saw that happening before.

What does the ... in your window.open(...) actually hold?
If it holds a normal URL, windowname, etc this shouldn't happen.
alert( cc ); // reports "object Object"

Why would 2 subsequent alerts showing the same object give diffent
results if you didn't touch anything in between?

My guess is you are making a mistake somewhere, or not showing us the
whole story.

Regards,
Erwin Moller

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
D

David Mark

It just gets odder and odder.

function popup() { // called on button click
    var cc = window.open( ... ) // window pops up
    alert( cc ); // alert appears after window is closed. reports
"object Window"

No, you just didn't see it until you closed the window. It was there
all along.
    alert( cc ); // reports "object Object"

So what? It is a host object. If it wants to report a different type
for closed windows, that is its prerogative.

And yes, you will need some basic mouse position reporting code.
Don't use a canned "drag and drop library" as they are mostly refuse.
 
T

The Natural Philosopher

Daniel said:
You'll probably want the content in a div rather than a separate
window. You can hide the div and position/show it when needed. Browsers
generally don't have the idea of "modal" windows in any case, so you'll
need to go this route.


yes. unhide a massive 'glass screen' at z-index 1, and overlay with our
popup div at z-index 2.

Nothing works till you remove the screen :)
 
M

Martin Rinehart

David said:
No, you just didn't see it until you closed the window. It was there
all along.

You're right. Opera launches new window in new tab, tricking me.
So what? It is a host object. If it wants to report a different type
for closed windows, that is its prerogative.

I don't care what it reports. Problem is, it morphs from Window to
Object between two consecutive alerts. I don't like sneeky vars that
change type when they think I'm not looking.

The following crap is not finished code, it's try stuff and see what
happens code.

--------------------------------------------------------------------------------------------

<! cc-popup.html - pop up a JavaScript Color Chooser >
<! copyright 2008, Martin Rinehart >

<html lang=en-US>

<head>
<title> CC Popup Button </title>

<meta http-equiv="Content-Script-Type" content="text/javascript">

<script>

function ccpop( who ) {
var cc = window.open( 'javascript:"";', '',
'top=100, left=100, width=450, height=300');
cc.document.write( "Hello from cc" );

alert( cc );
alert( cc );
}

</script>

<style>

font { color:blue; }

.script {
font:32pt 'Free Chancery' italic;
color:#404080
}

</style>

</head>

<body>

<table id=bar
bgcolor=cyan border=5 height=30px width=45px
style='position:relative; top:1px; left:108px;'
onclick=ccpop(this)>
<tr> <td> </td> </tr>
</table>

<center>
<hr width=80%>
<span class=script>
CC Popup
</span>
<hr width=80%>
<p>
<table id=foo
bgcolor=blue border=5 height=30px width=45px
onclick=ccpop(this)<tr> <td> </td> </tr>
</table>
</center>

</body>

</html>

<! end of cc-popup.html >
 
M

Martin Rinehart

Martin said:
I don't care what it reports. Problem is, it morphs from Window to
Object between two consecutive alerts. I don't like sneeky vars that
change type when they think I'm not looking.

Now I've got it. New window is opened on tab two, on which Opera also
shows content of tab one pre-window opening. Alert pops on tab one,
but I'm looking at tab two. Closing the window on tab two also closes
tab two and returns to tab one, which is paused because the alert is
modal. OK the alert and execution resumes, which is the second alert.
Since there is no more window, the var is now just an Object.

Now, you guys cheerfully inform me, all that remains to do to get my
Color Chooser working is to write a little windowing OS in JS. No
wonder I couldn't find a decent color chooser already written.
 
E

Erwin Moller

Martin Rinehart schreef:
Now I've got it. New window is opened on tab two, on which Opera also
shows content of tab one pre-window opening. Alert pops on tab one,
but I'm looking at tab two. Closing the window on tab two also closes
tab two and returns to tab one, which is paused because the alert is
modal. OK the alert and execution resumes, which is the second alert.
Since there is no more window, the var is now just an Object.

Now, you guys cheerfully inform me, all that remains to do to get my
Color Chooser working is to write a little windowing OS in JS. No
wonder I couldn't find a decent color chooser already written.

Personally I think decent color choosers are written inline, in a div
that can be hidden/shown. Popups are often blocked.

Regards,
Erwin Moller


--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top