javascript - 如何通过单击按钮打开 https 网站?

标签 javascript jquery

我正在使用的代码是

window.location.href = "https://www.google.com/"; 

但我停留在同一页面,没有转到google.com .我能够通过 http 页面完成这项工作。

window.location.href = "http://www.tutorialspoint.com/mongodb/mongodb_insert_document.htm"; 

这是相同的完整代码

<form name="form1" onsubmit="submis()" action="/post.php" method="POST"

和函数submis()

function submis()
{
     window.location.href = "https://www.google.com/";    
}

和 post.php

if (!empty($_POST))
{
//saving the contents of the post request to a file.
}

最佳答案

<script>
        function goto(){
            window.location.href = "https://www.google.com/";
        }
    </script>

在html代码中<a href="#" onclick="goto()">go to google</a>

有效

关于javascript - 如何通过单击按钮打开 https 网站?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33405850/

相关文章:

javascript - 使用 JavaScript 添加和删除类

javascript - 即使放入错误的可放置对象,如何禁用可拖动对象

javascript - 如何将图像数据从node.js传输到html5 canvas?

javascript - 为什么我在尝试获取数字总和时得到 NaN

Jquery getJSON 不起作用,但 ajax 可以

javascript - jquery 不在 chrome 中运行,在 ff 中运行

javascript - IndexedDB 是否需要在升级时关闭?

javascript - 我如何在 Dojo form.select 选项中设置选择

javascript - 是否可以将箭头跨度移出 jssor 中的默认父容器?

javascript - jQuery 邮政编码验证不起作用