Solved

onmousedown with IE

Posted on 2001-07-10
2
961 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

820 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