How to keep swapped image on mouse click.

N

novicesue

I've searched through the postings and help files, but still haven't found
the right code. How do I keep the image that becomes active on mouse down to
stay active (onscreen) when the image is clicked to link to another page -
and not disappear with mouseover? I used the code below for interactive
buttons from FP 2003 and subbed in my own images.

When I click on the image to link to the "pto_main" page, I want the
"bt-pto3" image to stay on the screen to indicate the section I'm in, rather
than be overridden by subsequent mouse events. If can do, how to? Be nice,
I'm an OOL novice. I know HTML, but not javascript. Any help would be
greatly appreciated.

<a href="pto_main.htm">

<img border="0" id="img11" src="images/bt-pto1.jpg" width="118" height="32"
alt="Parent_PTO Pages"
onmouseover="FP_swapImg(1,0,/*id*/'img11',/*url*/'images/bt-pto2.jpg')"
onmouseout="FP_swapImg(0,0,/*id*/'img11',/*url*/'images/bt-pto1.jpg')"
onmousedown="FP_swapImg(1,0,/*id*/'img11',/*url*/'images/bt-pto3.jpg')"
onmouseup="FP_swapImg(0,0,/*id*/'img11',/*url*/'images/bt-pto2.jpg')"
 
R

Ronx

In the link, you could remove the
onmouseup="FP_swapImg(0,0,/*id*/'img11',/*url*/'images/bt-pto2.jpg')"

However the next page (pto_main.htm) will still load with the original
button showing. In this page change the code to:

<a href="pto_main.htm">
<img border="0" id="img11" src="images/bt-pto3.jpg" width="118" height="32"
alt="Parent_PTO Pages"
onmouseover="FP_swapImg(1,0,/*id*/'img11',/*url*/'images/bt-pto2.jpg')"
onmouseout="FP_swapImg(0,0,/*id*/'img11',/*url*/'images/bt-pto3.jpg')"

--
Ron Symonds
Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.
FrontPage Support:
http://www.frontpagemvps.com/
 
N

novicesue

Thx much for your quick response, Ronx. I'd already tried removing the
mouseup - with the results you noted. The problem with your suggestion (I
think) is that I'm using frames, and the navigation buttons are in one frame
that essentially remains stationary, and linked to pages load into a separate
(the main) frame, (except in the case of a few outside links where the issue
is moot). Sorry I forgot to convey that critical piece. Any ideas for that
scenario?
 
R

Ronx

With Frames, do not remove that onmouseup piece of code or the button will
stay pressed for ever.
--
Ron Symonds
Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.
FrontPage Support:
http://www.frontpagemvps.com/
 
N

novicesue

Yep - found that out already. Still begging a howto on getting that (button)
image to remain active (onscreen) when I click it to load the linked page
(i.e. how do I not lose the image to another mouse event).............

I know it's doable, cause I've seen it done on a ton of pages - just maybe
not with javascript?

Any more ideas/takers? Thx in advance for you benevolent beings.
 
J

Jens Peter Karlsen [FP-MVP]

More likely not with Frames.

Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
 
R

Ronx

I would use server-side scripting to rebuild the frames page and the
contents page, so every link would be of the form <a
href="default.asp?p=pagename.htm"><interactive button stuff</a>
default.asp would write out the frameset using pagename as the default page
for the main frame, and pass a parameter to contents.asp which would write
out the appropriate IB code for the correct pressed state.

However, I would not use frames.

You could search for CSS buttons, which will use the active state of the
link to display the pressed state. These load faster than IBs, and use a
lot less JavaScript.

Or do as I do and not bother about it - the page itself should say where you
are.
 
S

Stefan B Rusynko

Not possible w/o some scripting that identifies where/how the user came from

The hyperlinked page has No idea how you got to it
- clicking the linked image, or typing the URL, a bookmark or using some other link
Unless you pass (or set) some variable to the page when you click on the specific image

You would need to add a parameter to the link as say
<a href="pto_main.htm?id="img11">
Then on the receiving page (pto_main.htm) check for, or parse, the parameter and use a JavaScript write script to decide which
version of the image to display
With multiple images the process using client side scripting gets more complex

And the image state won't persist as you navigate away and back to the page,
- unless you use server side scripting to store the pressed "state" and render the image using server side coding based on that
parameters previous state
(again using a separate parameter for each image you want to "track")

IMHO
- not worth the effort or coding for more than say 1 or 2 images
- just add a border to the image and let the hyperlink colors (border) change on state changes
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Yep - found that out already. Still begging a howto on getting that (button)
| image to remain active (onscreen) when I click it to load the linked page
| (i.e. how do I not lose the image to another mouse event).............
|
| I know it's doable, cause I've seen it done on a ton of pages - just maybe
| not with javascript?
|
| Any more ideas/takers? Thx in advance for you benevolent beings.
|
| "Ronx" wrote:
|
| > With Frames, do not remove that onmouseup piece of code or the button will
| > stay pressed for ever.
| > --
| > Ron Symonds
| > Microsoft MVP (FrontPage)
| > Reply only to group - emails will be deleted unread.
| > FrontPage Support:
| > http://www.frontpagemvps.com/
| >
| >
| > | > > Thx much for your quick response, Ronx. I'd already tried removing the
| > > mouseup - with the results you noted. The problem with your suggestion (I
| > > think) is that I'm using frames, and the navigation buttons are in one
| > frame
| > > that essentially remains stationary, and linked to pages load into a
| > separate
| > > (the main) frame, (except in the case of a few outside links where the
| > issue
| > > is moot). Sorry I forgot to convey that critical piece. Any ideas for
| > that
| > > scenario?
| > >
| > > "Ronx" wrote:
| > >
| > > > In the link, you could remove the
| > > > onmouseup="FP_swapImg(0,0,/*id*/'img11',/*url*/'images/bt-pto2.jpg')"
| > > >
| > > > However the next page (pto_main.htm) will still load with the original
| > > > button showing. In this page change the code to:
| > > >
| > > > <a href="pto_main.htm">
| > > > <img border="0" id="img11" src="images/bt-pto3.jpg" width="118"
| > height="32"
| > > > alt="Parent_PTO Pages"
| > > > onmouseover="FP_swapImg(1,0,/*id*/'img11',/*url*/'images/bt-pto2.jpg')"
| > > > onmouseout="FP_swapImg(0,0,/*id*/'img11',/*url*/'images/bt-pto3.jpg')"
| > > > ></a>
| > > >
| > > > --
| > > > Ron Symonds
| > > > Microsoft MVP (FrontPage)
| > > > Reply only to group - emails will be deleted unread.
| > > > FrontPage Support:
| > > > http://www.frontpagemvps.com/
| > > >
| > > >
| > > > | > > > > I've searched through the postings and help files, but still haven't
| > found
| > > > > the right code. How do I keep the image that becomes active on mouse
| > down
| > > > to
| > > > > stay active (onscreen) when the image is clicked to link to another
| > page -
| > > > > and not disappear with mouseover? I used the code below for
| > interactive
| > > > > buttons from FP 2003 and subbed in my own images.
| > > > >
| > > > > When I click on the image to link to the "pto_main" page, I want the
| > > > > "bt-pto3" image to stay on the screen to indicate the section I'm in,
| > > > rather
| > > > > than be overridden by subsequent mouse events. If can do, how to? Be
| > > > nice,
| > > > > I'm an OOL novice. I know HTML, but not javascript. Any help would
| > be
| > > > > greatly appreciated.
| > > > >
| > > > > <a href="pto_main.htm">
| > > > >
| > > > > <img border="0" id="img11" src="images/bt-pto1.jpg" width="118"
| > > > height="32"
| > > > > alt="Parent_PTO Pages"
| > > > >
| > onmouseover="FP_swapImg(1,0,/*id*/'img11',/*url*/'images/bt-pto2.jpg')"
| > > > > onmouseout="FP_swapImg(0,0,/*id*/'img11',/*url*/'images/bt-pto1.jpg')"
| > > > >
| > onmousedown="FP_swapImg(1,0,/*id*/'img11',/*url*/'images/bt-pto3.jpg')"
| > > > > onmouseup="FP_swapImg(0,0,/*id*/'img11',/*url*/'images/bt-pto2.jpg')"
| > > > > ></a>
| > > > >
| > > >
| > > >
| > > >
| >
| >
| >
 
N

novicesue

Thanks, Guys (Ronx, Jens, Stefan). You've all been very helpful. It's
become clear that I'll have to lose the idea, since I don't have time (or the
ability yet) to dig into scripting that deep. Frustrating as a pre-OOL
programmer (painful to admit) to understand the logic that's needed but not
how to prg in script. Anywho, I'll give the CSS buttons idea a try.

I don't want to give up Frames as I'm creating a site for a school, and want
to give flexibility to others to create content pages w/o losing the overall
look and navigation scheme. Tried shared borders in lieu of frames for
another school and it caused problems every time someone else added to the
site (something I won't have control over).....

Appreciate all the help.
 
N

novicesue

Forgot to mention - also trying to learn about DWT's as an alternative to
using Frames. Would those of you in the know who've worked with them
recommend that route in lieu of Frames?
 
N

novicesue

I'm getting the hint - and well-noted advice from those far more experienced
than me. I've some reading and tinkering to do. Thx again so much. It's
great that us newbies have someone to turn to.
 
J

Jim Carlock

How about using an array to keep track of the pressed button?

// menu items - id, menuname, selected, url
var aMenuItems[[1,"menu1",0,"http://...zzz1url..."], \
[2,"menu2",0,"http://zzz2url"]];

Just make sure you only one item gets set to 1 (or -1) at any
given instant.

// parameters: selected MenuID
function viewPage(iMenuID) {
// code to release previously selected button
releasePage();
// code to depress button specified by iMenuID
// ...
aMenuItems[iMenuID][2] = 1; // set the element to pressed
}

function releasePage() {
var i;
// loop through to find the pressed menu item
for (i = 0; i < aMenuItems.length; i++) {
if (aMenuItems[2]) {
aMenuItems[2] = 0; // set variable to zero
// code to display the released button
// ...
break; // exit for loop
}
}
}

This should work well with frames (or no frames), as long as
the buttons are in a common frame and the javascript gets
loaded inside this particular frame (the topic frame).

You could also provide an iSelectedButton variable to keep
track of the pressed button, instead of putting it in the array.

The above scripting uses Hungarian notation where:

i => number
a => array
s => string
o => object
c => represents a class (or simulated class)

Hope this helps.
 

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

Top