p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   HTML Code Clinic (http://p2p.wrox.com/forumdisplay.php?f=90)
-   -   links to a page when a button is clicked (http://p2p.wrox.com/showthread.php?t=6964)

hosefo81 December 7th, 2003 12:29 AM

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>



jacob December 7th, 2003 05:59 AM

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.

joefawcett December 7th, 2003 06:10 AM

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

Imar December 7th, 2003 06:24 AM

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.

jacob December 7th, 2003 06:47 AM

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

the button examples

[^]

Jacob.


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

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