Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to trigger onclick event in NS4 ?

Posted on 2002-07-23
9
Medium Priority
?
307 Views
Last Modified: 2007-11-27
Hi,

I have in my page a "A" tag with an onclick event associated.  I would like to programatically trigger this onclick event.  I do that with the following block of code. It works with IE but not with netscape 4. When i try that code with netscape 4 I have the following error message "mnuTop_2 has no properties !"
Thanks in advance.

Guillaume.


if (ns4==1)
{
   obj = document.layers["divSlideCont"]
   obj = obj.layers["divSlide1"]          
   obj.mnuTop_2.onclick()
}
else
{
   sName = "mnuTop_" + num
   document.all(sName).onclick()
}
0
Comment
Question by:anderlecht
9 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 7171537
obj.document.links[0].onclick()

CJ
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 7171538
with 0 being the index of that link.

CJ
0
 

Author Comment

by:anderlecht
ID: 7173691
It seems that it is impossible to trigger programatically the onclick event in NS4 !
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 10

Expert Comment

by:zvonko
ID: 7173737
Does this event you try to fire by script react to real mouse clicks?

0
 

Author Comment

by:anderlecht
ID: 7173762
Yes, when i click on my link it works
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 7173775
Check this script:

<html>
 <head>
 
 </head>
 
 <body>
  <a href="" onClick="alert('link 1 clicked');return false">Link 1</a>
  <a href="#" onClick="document.links[0].onclick();return false">Fire link 1</a>
 </body>
</html>
0
 
LVL 22

Accepted Solution

by:
CJ_S earned 800 total points
ID: 7173785
or this script for when the link is in a div

<html>
 <head>
  <script language="javascript">
  <!--
   function clickit()
   {
             lObj = document.layers?document.layers["mydiv"].document.links[0]:document.all["link0"];
             if(lObj) lObj.onclick();
   }
  //-->
  </script>
 </head>

 <body>
  <a href="#" onClick="clickit();return false">Fire link 1 in div</a>

  <div id="mydiv" style="position:absolute;visibility:visible;top:200px;left:100px;">
   <a href="" onClick="alert('link 1 clicked');return false" id="link0">Link 1</a>
  </div>
 </body>
</html>
0
 
LVL 12

Expert Comment

by:ahosang
ID: 8330316
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

points to CJ_S
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
ahosang
EE Cleanup Volunteer
0
 

Expert Comment

by:modulo
ID: 8395869
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question