Frames and Javascript (Oh, the pain!)

O

Owen Jacobson

Salve.

I'm working on a prototype web-based frontend for an application[0] as
part of a proposal at work. Development is on a Windows server[1] using
IIS[1]; installing extra modules like PHP or ActiveState Perl, while
possible, will seriously impact the prototype evaluation later.

This is a strictly internal web tool, and not meant for the internet at
large; nonetheless, I'd like to keep it as standards-compliant as
possible. The target browser right now is Internet Explorer[1], but I'd
like it to work properly under as many Javascript-enabled user agents as
possible and be at least usable under any HTTP agent. That latter
requirement works, right now.

Right now, the frontend is two frames[1]; the top one ("display") contains
a simple HTML page that contains an image pulled from the application
itself, while the bottom frame ("control") has a pair of forms for
manually entering queries for the application.

One of the two queries involves querying a pixel on the image for feature
information. Right now, the form requires you to type in the X and Y
coordinate of the pixel you'd like to query. I'd like to be able to query
by clicking directly on the image in "display". For a variety of reasons,
I'd rather implement this on the client side than write more server-side
code; Javascript is the obvious choice for that.

Is there any way I can, when the image in "display" is clicked, transmit
the relative x,y coordinate of the click to the relevant fields in the
form on frame "control" and then submit the form?

[0] An implementation of the OpenGIS Web Map Service specification
[1] Chorus: "Doctor, it hurts when I do this!"
 
B

brucie

in post: <
Owen Jacobson said:
I'm working on a prototype web-based frontend for an application[0] as
part of a proposal at work. Development is on a Windows server[1] using
IIS[1]; installing extra modules like PHP or ActiveState Perl, while
possible, will seriously impact the prototype evaluation later.

shoot yourself in the head. it wont hurt as much, be much easier and the
end result will pretty much be the same.
This is a strictly internal web tool, and not meant for the internet at
large; nonetheless, I'd like to keep it as standards-compliant as
possible. The target browser right now is Internet Explorer[1],

standard compliant in the most non standards compliant browser?
Right now, the frontend is two frames[1];
aahhhaaaaaaa

One of the two queries involves querying a pixel on the image for feature
information. Right now, the form requires you to type in the X and Y
coordinate of the pixel you'd like to query. I'd like to be able to query
by clicking directly on the image in "display". For a variety of reasons,
I'd rather implement this on the client side than write more server-side
code; Javascript is the obvious choice for that.

server side would make very much more sense and be infinitely simpler.

1. ismap the image
2. click on image
3. coords of pixel sent to server side script
4. server side script does whatever you want it to.
5. leave an hour earlier and go to the pub
6. easy
 
O

Owen Jacobson

On Thu, 01 Apr 2004 10:47:16 +1000, brucie wrote:

Sup, brucie. :) Warms my heart to see you back.
in post: <
Owen Jacobson said:
I'm working on a prototype web-based frontend for an application[0] as
part of a proposal at work. Development is on a Windows server[1] using
IIS[1]; installing extra modules like PHP or ActiveState Perl, while
possible, will seriously impact the prototype evaluation later.

shoot yourself in the head. it wont hurt as much, be much easier and the
end result will pretty much be the same.

It gets better. Consider, if you will, the logic of dictating the above
in the same breath as "Oh, and we'll be porting it to Solaris later, too."
This is a strictly internal web tool, and not meant for the internet at
large; nonetheless, I'd like to keep it as standards-compliant as
possible. The target browser right now is Internet Explorer[1],

standard compliant in the most non standards compliant browser?

In the hopes of convincing manglement that supporting things besides IE is
not only a good idea, but fairly easy (actually, in my experience easier,
but try convincing a Microsoft shop of that) too.
server side would make very much more sense and be infinitely simpler.

1. ismap the image
2. click on image
3. coords of pixel sent to server side script
4. server side script does whatever you want it to.
5. leave an hour earlier and go to the pub
6. easy

Got any scripting proposals that aren't ASP (because I'll have to port it
to Solaris later; see above) or C++ (which is, admittedly, what the rest
of the app is in)? I'm all ears, because I know the way I'm doing it is
dumb; it just seems the least dumb of a plethora of irritating options.
 
J

Jeff Thies

Right now, the frontend is two frames[1]; the top one ("display") contains
a simple HTML page that contains an image pulled from the application
itself, while the bottom frame ("control") has a pair of forms for
manually entering queries for the application.

One of the two queries involves querying a pixel on the image for feature
information. Right now, the form requires you to type in the X and Y
coordinate of the pixel you'd like to query. I'd like to be able to query
by clicking directly on the image in "display". For a variety of reasons,
I'd rather implement this on the client side than write more server-side
code; Javascript is the obvious choice for that.

You need to be over in comp.lang.javascript!

Something like:

<script type="text/javascript">
document.omousedown=getPosition;

function getPosition(){
x=event.x; y=event.y // that's an IE only reference

frame_name.document['form_name']['form_element_name'].value=x;

....
}

....

Season to taste.

Cheers,
Jeff
Is there any way I can, when the image in "display" is clicked, transmit
the relative x,y coordinate of the click to the relevant fields in the
form on frame "control" and then submit the form?

[0] An implementation of the OpenGIS Web Map Service specification
[1] Chorus: "Doctor, it hurts when I do this!"
 
R

Richard Cornford

Owen Jacobson wrote:
Is there any way I can, when the image in "display" is clicked,
transmit the relative x,y coordinate of the click to the relevant
fields in the form on frame "control" and then submit the form?
<snip>

Yes it is easy, given a sub set of javascript enabled/capable browsers
(that excludes a number of PDA and embedded browsers that don't make the
relative position of page element available, but, of those, the ones
that I could name don't support frames anyway so they are already out of
the picture).

Any mouse event will provide an event object that holds numerous mouse
position values. The simples approach for cross-browser support is to
normalise those values into offsets into the HTML page (as opposed to
offsets over the image, screen offsets or client area offsets). Then
subtracting the offset of the image in the HTML document gives the
co-ordinates over the image, and then it is just a matter of writing the
values into the - value - properties of the form elements in the other
frame.

For reliability a server-side solution would be better, but optimum
might be to implement the javascript to short-circuit the request to the
server whenever it was capable of doing the job locally (though that
would need to be actively verified because the ability to execute a
client-side script does not imply that the browser will facilitate the
task it wants to undertake).

Richard.
 
B

brucie

in post: <
Owen Jacobson said:
Sup, brucie. :) Warms my heart to see you back.

you're sick
Got any scripting proposals

the above was about it. once you ismap the image the coords of the pixel
are passed to the server. instead of passing the coords to a .map file
pass them to a script. get the script to do whatever it is you need
doing.
that aren't ASP

asp is the spawn of beelzebub
(because I'll have to port it to Solaris later; see above) or C++

haven't touched c/c++ since the late '80s.
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top