Go Back   CodingForums.com > :: Client side development > General web building

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-22-2002, 02:26 PM   PM User | #1
dhtmlhelp
Regular Coder

 
Join Date: Jun 2002
Location: London, UK
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
dhtmlhelp is an unknown quantity at this point
onclick td

Hi,

I am trying to apply an onclick event to a <td>. The event should look something like this:

<td onclick="test/test.html" target="main">
</td>

It is not working though; the error message I get is "test is not defined". Would someone know how I can fix this?

DHTMLHELP
dhtmlhelp is offline   Reply With Quote
Old 06-22-2002, 03:05 PM   PM User | #2
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
Onclick doesn't work that way. This might work - not good at js

onclick="document.location='test/test.html'"
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 06-22-2002, 03:13 PM   PM User | #3
dhtmlhelp
Regular Coder

 
Join Date: Jun 2002
Location: London, UK
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
dhtmlhelp is an unknown quantity at this point
Hi Nightfire,

it works fine except how can I include target="main" in the onclick event ???

DHTMLHELP
dhtmlhelp is offline   Reply With Quote
Old 06-22-2002, 03:20 PM   PM User | #4
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
Erm, try this

document.main.location='test/test.html'

Might work, might not
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 06-22-2002, 03:30 PM   PM User | #5
dhtmlhelp
Regular Coder

 
Join Date: Jun 2002
Location: London, UK
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
dhtmlhelp is an unknown quantity at this point
Hi Nightfire,

nope, doesn't work.

DHTMLHELP
dhtmlhelp is offline   Reply With Quote
Old 06-22-2002, 04:49 PM   PM User | #6
boxer_1
Regular Coder

 
Join Date: May 2002
Location: Maine, USA
Posts: 574
Thanks: 0
Thanked 0 Times in 0 Posts
boxer_1 is an unknown quantity at this point
Hi, try this:

<td onclick="parent.main.location=''test/test.html'">
Cell contents...
</td>

Should do the trick .
__________________
boxer_1
CodingForums Moderator
"How did a fool and his money get together in the first place?"
boxer_1 is offline   Reply With Quote
Old 06-22-2002, 07:01 PM   PM User | #7
boxer_1
Regular Coder

 
Join Date: May 2002
Location: Maine, USA
Posts: 574
Thanks: 0
Thanked 0 Times in 0 Posts
boxer_1 is an unknown quantity at this point
I put an example thinking it might be more helpful to see it work (not all browsers will support the onClick event handler in a table cell):

http://www.kynd.com/~buyswap/onClick_td_frame.html

Here's the code that loads into the frame on the right (named 'other'):

<html>
<head>
<title></title>
</head>
<body>
<p>
This page is loaded into the frame named other.
</p>
<table>
<tr>
<td onclick="parent.main.location='http://www.codingforums.com/'">
Cell contents, <b>click here</b>.
</td>
</tr>
</table>
</body>
</html>

Just in case you were still having trouble .
__________________
boxer_1
CodingForums Moderator
"How did a fool and his money get together in the first place?"
boxer_1 is offline   Reply With Quote
Old 06-22-2002, 09:06 PM   PM User | #8
dhtmlhelp
Regular Coder

 
Join Date: Jun 2002
Location: London, UK
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
dhtmlhelp is an unknown quantity at this point
Hi boxer,

it doesn't work yet. I am thinking is it because I am not specifying http. Below is how the td looks like:

<td width="180" bgcolor="#F4F4FF" onmouseover="this.style.backgroundColor='#EEEEFF'" onmouseout="this.style.backgroundColor='#F4F4FF'" onclick="parent.main.location='ml/ml.html'" style="cursor:hand;">

</td>

the error message I receive is:

parent.main is null or not an object

Does IE support the onclick event in tables?

DHTMLHELP

Last edited by dhtmlhelp; 06-22-2002 at 09:22 PM..
dhtmlhelp is offline   Reply With Quote
Old 06-22-2002, 09:40 PM   PM User | #9
boxer_1
Regular Coder

 
Join Date: May 2002
Location: Maine, USA
Posts: 574
Thanks: 0
Thanked 0 Times in 0 Posts
boxer_1 is an unknown quantity at this point
Quote:
Originally posted by dhtmlhelp
Hi boxer,

it doesn't work yet. I am thinking is it because I am not specifying http. Below is how the td looks like:

<td width="180" bgcolor="#F4F4FF" onmouseover="this.style.backgroundColor='#EEEEFF'" onmouseout="this.style.backgroundColor='#F4F4FF'" onclick="parent.main.location='ml/ml.html'" style="cursor:hand;">

</td>

the error message I receive is:

parent.main is null or not an object

Does IE support the onclick event in tables?

DHTMLHELP
As long as the path to the document (ml/ml.html) you specify is correct, it should work. If you place the html document in the same directory as the rest of your pages you can just use 'ml.html' as your path. The 'http' was just for the pupose of my example.

As to your question asking if IE supports the onclick event handler in table cells...well, it depends on the version. In IE 6, yes. Did the example I posted for you work?

Using the onclick event handler in a table cell is not very cross-browser and probably not too good of an idea unless you creating an intranet site where everyone with access to the page has a browser that supports it.

See here for more information on the onclick event handler:

http://developer.netscape.com/docs/m...rs.htm#1119802
__________________
boxer_1
CodingForums Moderator
"How did a fool and his money get together in the first place?"
boxer_1 is offline   Reply With Quote
Old 06-22-2002, 10:51 PM   PM User | #10
dhtmlhelp
Regular Coder

 
Join Date: Jun 2002
Location: London, UK
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
dhtmlhelp is an unknown quantity at this point
Hi,

I am using IE6. I still get the following error message:

parent.main is null or not and object

would you know why?

DHTMLHELP
dhtmlhelp is offline   Reply With Quote
Old 06-22-2002, 11:38 PM   PM User | #11
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
Perhaps top.main instead of parent.main?

Nested framesets may be causing the problem with parent...
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 06-22-2002, 11:40 PM   PM User | #12
ACJavascript
Regular Coder

 
Join Date: Jun 2002
Location: FL, USA
Posts: 734
Thanks: 0
Thanked 0 Times in 0 Posts
ACJavascript is on a distinguished road
HI dhtmlhelp,

You would only get that kind of error when the frame isn't there.

So don't test it alone. You must test it within a frameset with one of the frames called main. It will work then.

If it doesn't then try this (but in a frame)

<td onClick="javascript:parent.main.location.href='ml/ml.html';">
Bla Bla
</td>



Hope this helps:):)
__________________
CYWebmaster.com - See why we dot com!!
ACJavascripts.com - Cut & Paste Javascripts!
SimplyProgram.com - Personal Blog
ACJavascript is offline   Reply With Quote
Old 06-23-2002, 12:33 AM   PM User | #13
dhtmlhelp
Regular Coder

 
Join Date: Jun 2002
Location: London, UK
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
dhtmlhelp is an unknown quantity at this point
Unhappy

Hi,

maybe I should have specified that the table is in an iframe within another iframe. The iframe with the table is called sg while the main iframe is called main. I have tried:

onClick="javascriptarent.main.location.href='ml/ml.html';"

but still get the same error.

DHTMLHELP
dhtmlhelp is offline   Reply With Quote
Old 06-23-2002, 12:35 AM   PM User | #14
dhtmlhelp
Regular Coder

 
Join Date: Jun 2002
Location: London, UK
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
dhtmlhelp is an unknown quantity at this point
Cool

WHei,

top.main works !!!!

thanks guys.

DHTMLHELP
dhtmlhelp is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:40 AM.


Advertisement
Log in to turn off these ads.