Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onclick button issue?

Status
Not open for further replies.
Mar 29, 2002
33
US
I'm trying to create a press feature for my navigation buttons (created in photoshop). I know that I need two images, one for the up position and one for the down position. I put together the language below, but I can't get the whole thing to work. The buttons are in the ‘content’ portion of the frame. The buttons should display new pages in ‘main’ frame portion of the page. I think I need the 'onclick' event, but i'm unclear on that... Any help or suggestions would be greatly appreciated.
Thanks, Red

<p>

<INPUT TYPE="button" VALUE="homeupbutton.jpg" onCLick="main">
<a href = "main.html" target = "main">
<img src = "home.jpg" width = "120"
height = "30" alt = "Home" />
</a></br>
 
Quick sample:
Code:
<img src="home.jpg" onmouseover="this.src='homeupbutton.jpg'" width="120" height="30" alt="Home" onClick="document.frames['main'].location='main.html'" style="cursor:hand">
 
Supra,

I took your script and modified the onmouseover to 'onclick', however the button stays in the down position after I release the mouseclick. How can I get the button to operate like the standard buttons on the navigation bar found on most browsers? Thank you again for the previous help.

Red-

 
Try using the onMouseDown event to show the Pressed image.

You'll also need to add somehthing to the onMouseUp event to display the released button.

Hope that helps
 
All right, I'm back after being away from the house for some time. I'm still receiving an error with the script I’ve put together with previous help from several individuals. The button works great (swaps images of 'up' & 'down'), however the frame 'main' does not swap pages on the onClick command. Any help would be greatly appreciated.
Thanks, Red

<img src="homebuttonup.jpg" onMouseDown="this.src='homebuttondown.jpg'" onMouseup="this.src='homebuttonup.jpg'" onClick="document.frames['main.html'].location='home.html'" style="cursor:hand" width="120" height="30" alt="Home">
 
Can't anybody help a brother out with the question above?

Thanks, Red
 
Code:
onClick="document.frames['main.html'].location='home.html'"

is there a frame named main.html? Or just main?
 
There's a frame named 'main'. I have several buttons in a content frame on the left portion of the screen. I would like to allow buttons to update the frame ‘main' when pressed. I have the up/down Mouse click working fine so the buttons look like they're being pressed. However I get an error on the page, I believe when it runs the code you pasted above. Any further help would be great.
Thanks, Red
 
what 13sio is saying is that you need to change
frames['main.html']

to
frames['main']

Code:
<img src="homebuttonup.jpg" onMouseDown="this.src='homebuttondown.jpg'" onMouseup="this.src='homebuttonup.jpg'" onClick="document.frames['main'].location='home.html'" style="cursor:hand" width="120" height="30" alt="Home">

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 
I tried 'main' instead of 'main.html', but I continue to get the error "error on page" at the bottom of the browser. As I mentioned previously, the button works properly from a visual standpoint, it just doesn’t load the page properly. I put the source from my index page below, along with the updated script I was using. Any help again would be greatly appreciated.

Thanks, Red

INDEX PAGE::
<frameset framespacing="0" border="0" frameborder="0" rows="70,*,90">
<frame name="header" scrolling="no" noresize target="content" marginwidth="0" marginheight="0" src="header.html">
<frameset cols="170,*">
<frame name="content" target="main" scrolling="auto" noresize marginwidth="10" marginheight="15" src="content.html">
<frame name="main" scrolling="auto" noresize marginwidth="10" marginheight="15" style="list-style-type: disc" src="main.html">
</frameset>
<frame name="footer" scrolling="no" noresize target="content" marginwidth="0" marginheight="0" src="footer.html">
<noframes>
<body style="margin-top: 0; margin-bottom: 0">

<p>This page uses frames, but your browser doesn't support them.</p>

</body>
</noframes>
</frameset>

UPDATED SCRIPT:
<img src="homebuttonup.jpg" onMouseDown="this.src='homebuttondown.jpg'"
onMouseup="this.src='homebuttonup.jpg'"
onClick="document.frames['main'].location='home.html'"
style="cursor:hand" width="120" height="30" alt="Home">
 
well then, what error are you getting? double-click on the error icon.


=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 
jemminger

Char: 1
Error: 'document.frames.main' is null or not an object
Code: 0

Do I need set frame ‘main’ to some value, similar to setting a field/column to integer, string, double..?

Thanks, Red
 
Try to change
Code:
onClick="document.frames['main'].location='home.html'"
into
Code:
onClick="parent.main.location='home.html'"
hope it helps!
 
13sio/jemminger,

Thank you both for the assistance with this simple, but yet annoying script. The last bit (parent) worked beautifully.

Thanks again, Red-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top