Solved

onmousedown with IE

Posted on 2001-07-10
2
958 Views
Last Modified: 2008-03-10
Hi to all

I create a table dynamically and place a link in a cell like this:
j=1;
Anchor=document.createElement("A");
Anchor.href='javascript:mylink(' +j+ ');';
Anchor.id = 'MyAnchor'+j;
strAnchor = document.createTextNode(listOfMenus[j].text);
Anchor.appendChild(strAnchor);
Anchor.setAttribute("onmousedown","javascript:changelink(event.button,this,"+j+");");

function changelink(button,objref,j)
{   strServer = "www.myserver.com/";
     switch(button)
     {
     case 1:
     objref.href = strServer + default.htm";
     return true;
     break;
     case 2:
     objref.href = strServer + rightklick.htm;
        return true;
     break;
     case 3:  //Netscape
     objref.href = strServer + rightklick.htm;
     return true;
     break;
     default:
     return true;
     }
}
function mylink(j)
{ //do anything important
 return true;}

Unfortunately this does not work under IE5.5 or 6.0. Under Netscape 6.0 it works very well.
When I klick the right mouse-button on the link in IE nothing happens, not even the changelink() routine will be executed.
The question is then how to set dynamically the onmousedown-Attribute in a way that it works also with IE. Is setattribute() not enough?

Greets Alesch
0
Comment
Question by:alesch
2 Comments
 
LVL 14

Accepted Solution

by:
avner earned 101 total points
ID: 6269129
the set Attribute won't work use :

Anchor.onmousedown=new Function('changelink(event.button,this,"+j+")');
0
 

Author Comment

by:alesch
ID: 6288919
Hi avner

Thanks, it worked.

Alesch

(Sorry for the late message)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jQuery scrollTop 2 40
Javascript create file issue 4 45
Google Sheets Script 21 51
Form with Modals 16 42
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

932 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now