I
ICPooreMan
The following is a very simple example of what I want to do take an
elements oncontextmenu and changing it dynamically onclick of that
same element. The code below will fail unless you change the line
document.getElementById('div1').setAttribute('oncontextmenu',
someText);
to
document.getElementById('div1').setAttribute('oncontextmenu',
function(){alert('World World');return false;});
<html>
<head>
<title> testing </title>
<script><!--
function doSomething(){
var someText =
String(document.getElementById('div1').getAttribute('oncontextmenu'));
someText = someText.replace("Hello","World");
document.getElementById('div1').setAttribute('oncontextmenu',
someText);
}
//-->
</script>
</head>
<body>
<div id="div1" onclick="doSomething();return false;"
oncontextmenu="alert('Hello World');return false;"> Hello </div>
</body>
</html>
The string I generate in the example is what the function should say
so is there anyway to take that string and make a literal translation
in IE?
I posted a while back something similar because I thought there was a
problem with the setAttribute function, no real great answers were
found but after further inspection it turns out setAttribute works it
just won't translate a string to a function. PS only IE has problems
with this I've tested with 6+7
elements oncontextmenu and changing it dynamically onclick of that
same element. The code below will fail unless you change the line
document.getElementById('div1').setAttribute('oncontextmenu',
someText);
to
document.getElementById('div1').setAttribute('oncontextmenu',
function(){alert('World World');return false;});
<html>
<head>
<title> testing </title>
<script><!--
function doSomething(){
var someText =
String(document.getElementById('div1').getAttribute('oncontextmenu'));
someText = someText.replace("Hello","World");
document.getElementById('div1').setAttribute('oncontextmenu',
someText);
}
//-->
</script>
</head>
<body>
<div id="div1" onclick="doSomething();return false;"
oncontextmenu="alert('Hello World');return false;"> Hello </div>
</body>
</html>
The string I generate in the example is what the function should say
so is there anyway to take that string and make a literal translation
in IE?
I posted a while back something similar because I thought there was a
problem with the setAttribute function, no real great answers were
found but after further inspection it turns out setAttribute works it
just won't translate a string to a function. PS only IE has problems
with this I've tested with 6+7