Solved

onmousedown with IE

Posted on 2001-07-10
2
964 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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

635 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