Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 7th, 2003, 12:29 AM
Authorized User
 
Join Date: Oct 2003
Location: KL, wilayah persekutuan, Malaysia.
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default links to a page when a button is clicked

How can i make the requested page loads in when the user presses a button?
My problem is in frame1.html where i want make links in frame.html target another frame.
In frame1, the first and second links(using image and hyperlinks) are successfully loaded in but the third link (using button)can't.
Below are my code. Please correct my code.

//frame.html
<html>
<head>
<title>Frame Example</title>
</head>
<form name="form2">
<frameset cols="15%, *">
<frame Src="frame1.html" Name="frame1">
<frame Src="frame2.html" Name="frame2">
</frameset>
</form>
</html>

//frame1.html
<html>
<head>
<style type="text/css">
#butprod { position:absolute; left:10px; top:10px; width:100px; height:30px; background:antiquewhite; cursor:hand;}
#butprod2 { position:absolute; left:10px; top:50px; width:100px; height:30px; background:antiquewhite; cursor:hand;}
#butprod3 { position:absolute; left:10px; top:90px; width:100px; height:30px; background:antiquewhite; cursor:hand;}
</style>
</head>
<body>
<form name="form1">
<a href="frame2.html" target="frame2">Sales by Product</a><br><br>
<a href="frame3.html" target="frame2"><img src="free88.gif"></a><br><br>
<a href="frame4.html" target="frame2"><input type="button" value="Sales by Customer"></a><br><br>
</form>
</body>
</html>


Reply With Quote
  #2 (permalink)  
Old December 7th, 2003, 05:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have got a solution for you. Try something like this...
Code:
<INPUT type='button' value='load in other frame' onclick="top.frame1.location.href='someDocument.html';">
You do not need the form tag then.

Jacob.
Reply With Quote
  #3 (permalink)  
Old December 7th, 2003, 06:10 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Or with your code add an onclick handler to the button:
Code:
<a href="frame4.html" target="frame2"><input type="button" value="Sales by Customer" onclick="this.parentElement.click();"></a>
--

Joe
Reply With Quote
  #4 (permalink)  
Old December 7th, 2003, 06:24 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You can't nest a button inside a <a> tag. When you click the button, its click event will fire, but it won't take you to the URL referenced in the <a> tag.

To change the address from a button, try this:

<input type="button" value="Sales by Customer" onclick="window.parent.frames.frame2.document.loca tion.href='Frame4.html';">

When you click the button, the document in the second frame (referenced as window.parent.frames.frame2 where parent is the entire frameset that has a frame collection which contains a frame called frame2) has it document.location.href changed to the requested address.

Does this help?

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #5 (permalink)  
Old December 7th, 2003, 06:47 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Now three suggestions have been posted. I have put them on a page here...

the button examples



Jacob.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form does not open when commandbar button clicked Arsi BOOK: Professional Outlook 2007 Programming ISBN: 978-0-470-04994-5 21 March 5th, 2009 04:03 AM
How to know whick button was clicked. KingArthur Struts 1 February 22nd, 2006 07:12 AM
Determining Which Button Was Clicked BrianWren ASP.NET 1.0 and 1.1 Basics 3 May 5th, 2005 03:24 PM
How to tell which button clicked emily PHP How-To 2 November 30th, 2004 01:35 PM



All times are GMT -4. The time now is 01:32 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.