JavaScript打开弹出窗口并模拟鼠标单击特定位置

时间:2016-09-25 04:20:52

标签: javascript jquery popup window popupwindow

我需要打开弹出窗口" Page1.html"然后自动点击按钮" VOTE"然后将该页面重定向到" Page2.html"。

我知道以下用于打开弹出窗口的代码" Page1.html"

<script type="text/javascript">
function makeNewWindow()
{
winchlildren = window.open("./page1.html","winchlildren","height=600,width=85")
}
</script>

我有按钮所在的表单。

<!DOCTYPE html>
<html>
<head></head>
<body>
<div class="votelog_info">
    <div class="votelog_nav">
        <div class="vote_nav is_voteing">
            <form method="post">
            <input type="hidden" name="form_pass" value="form_pass_qk9telqr2G4hU" />
            <input type="hidden" name="id" value="norrcon" />
            <button type="submit" class="vote for" name="submit">Vote</button></form>
        </div>
    </div>
</div>
</body>
</html>

按下此按钮后,我希望将该页面重定向到&#34; Page2.html&#34;
我希望这个过程在后台和全屏尺寸下完成 谢谢!
埃德加。

1 个答案:

答案 0 :(得分:0)

正如您已将此问题提交给Jquery,您可以使用JS完成它:

<script type="text/javascript">
    function makeNewWindow() {
        winchlildren = window.open("./page1.html","winchlildren","height=600,width=85");

        $('.is_voteing input[name="submit"]').click();
    }
    $(".is_voteing input[name="submit"]').click(function(){
        // do voting functionality when button is clicked
        // AJAX is preffered, if process to be done in the background
        . . .
        //Redirect completely to page2.html (full screen size, as you reffered)
        window.location = "./page2.html";
    });
</script>

然后在页面上的任何事件上调用makeNewWindow()