• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

Link using javascript without onclick

Hi all,

I have a function call setTab that changes the tabs in a menu when clicking on the change to different tabs links.
The links have this structure:
<a  href='' onclick='parent.setTab(12345);return false;'>I change to tab number 12345</a>
Great up till here, everything works wonderfully.

Now I need to change my links, I have to introduce some flash to click on the different tabs. The problem is that this piece of flash does not accept the tag onclick.
I cannot change the setTab function or the piece of flash (it would need to expend a lot of time doing it that I don't have  :(( )
So the solution is to change the link:
<a  href='' onclick='parent.setTab(12345);return false;'>I change to tab number 12345</a>
It should do what it does now but without using the onclik tag .. how can I do  that??

Thanks a ton in advance!
0
Dada44
Asked:
Dada44
  • 6
  • 5
1 Solution
 
sunithnairCommented:
try it this way
<a  href='javascript:parent.setTab(12345);return false;'>I change to tab number 12345</a>

Open in new window

0
 
sunithnairCommented:
or this way
<a  href='javascript:parent.setTab(12345);'>I change to tab number 12345</a>

Open in new window

0
 
Dada44Author Commented:
sunithnair, thanks a lot for answering.
With your first post I get this error in Firebug's console:
return not in function
and nothing else happens.
And using the code in your second post I get a new page with just the word false and  javascript:parent.setTab(12345); in the address bar....

Here's the function just in case it helps (sorry, I should have included it in my first post!):

<script type="text/JavaScript">
function setTab(tab) {
    parent.setTab(tab);
    return false;
}
</script>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
sunithnairCommented:
Try removing the return false from the setTab function. Sample code attached
<html>
<head>
<script type="text/JavaScript">
function setTab(tab) {
 alert(tab);
}
</script>
</head>
<body>
</body>
<a href='javascript:setTab("Hello")'>hello</a>
</body>
</html>

Open in new window

0
 
Dada44Author Commented:
no sorry, without the return false firebug shows a too much recursion error and nothing else happens :((((
0
 
sunithnairCommented:
Why do you refer to the parent in the script? Is it changing the tab in the parent window?
<script type="text/JavaScript">
function setTab(tab) {
    parent.setTab(tab);
    return false;
}
</script>

Open in new window

0
 
Dada44Author Commented:
yes Is it changing the tab in the parent window..
0
 
sunithnairCommented:
Is it possible to show me a working version of the page hosted somewhere?
0
 
Dada44Author Commented:
void was the solution, in case someone needs it:
javascript:void(parent.setTab(12345));
0
 
Dada44Author Commented:
thanks for your help!
0
 
sunithnairCommented:
Is it like this then?
<a href='javascript:void(parent.setTab(12345));'>12345</a>

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now