1. 程式人生 > >C# webBrowser寫模擬器時的javascript指令碼呼叫問題

C# webBrowser寫模擬器時的javascript指令碼呼叫問題

function moveElement(pxToMove)
{
var sliderKnob = document.getElementsByClassName("gt_slider_knob")[0];
var boxRect = sliderKnob.getBoundingClientRect();
var move = createEvent('mousemove', boxRect.left + sliderKnob.offsetLeft + pxToMove, boxRect.top + sliderKnob.offsetTop); 
var down = createEvent('mousedown', boxRect.left + sliderKnob.offsetLeft, boxRect.top + sliderKnob.offsetTop);
var up = createEvent('mouseup'); 
sliderKnob.dispatchEvent(down); 
document.dispatchEvent(move);
sliderKnob.dispatchEvent(up);
}