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

x
?
Solved

onmousedown with IE

Posted on 2001-07-10
2
Medium Priority
?
969 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 404 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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

916 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