Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
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
 
Old December 7th, 2003, 12:29 AM
Authorized User
 
Join Date: Oct 2003
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>


 
Old December 7th, 2003, 05:59 AM
Friend of Wrox
 
Join Date: Jun 2003
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.
 
Old December 7th, 2003, 06:10 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
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
 
Old December 7th, 2003, 06:24 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
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.
 
Old December 7th, 2003, 06:47 AM
Friend of Wrox
 
Join Date: Jun 2003
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.





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





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