小编Cof*_*use的帖子

在卸载/ beforeunload上使用Javascript发送帖子请求.那可能吗?

补充:我不能使用jQuery.我使用的是西门子S7控制单元,它有一个小的网络服务器,甚至无法处理80kB的jQuery文件,所以我只能使用原生的Javascript.从这个链接Ajax请求与JQuery页面卸载我得到我需要使请求同步而不是异步.可以用原生Javascript完成吗?

我从这里复制了代码:JavaScript发布请求,如表单提交

我想知道是否可以在关闭窗口/选项卡时调用它/使用jquery beforeunload或unload离开站点.应该可以吧?

function post_to_url(path, params, method) {
    method = method || "post"; // Set method to post by default if not specified.

    // The rest of this code assumes you are not using a library.
    // It can be made less wordy if you use one.
    var form = document.createElement("form");
    form.setAttribute("method", method);
    form.setAttribute("action", path);

    for(var key in params) {
        if(params.hasOwnProperty(key)) {
            var hiddenField = document.createElement("input");
            hiddenField.setAttribute("type", "hidden");
            hiddenField.setAttribute("name", key);
            hiddenField.setAttribute("value", params[key]);

            form.appendChild(hiddenField);
         }
    }

    document.body.appendChild(form); …
Run Code Online (Sandbox Code Playgroud)

javascript http-post

13
推荐指数
1
解决办法
6360
查看次数

动态组装var

如何在没有eval的情况下在运行时组装Javascript中的var?

var lc = $('.bezeichnung-1').length;
for (var lt = 1; lt <= lc; lt++) {
    eval("var neuerwert"+lt+"=0;"); // this works but I don't want to use it because I read that eval is bad
}


var lc = $('.bezeichnung-1').length;
for (var lt = 1; lt <= lc; lt++) {
    window["var neuerwert"+lt] = 0; // this does not work
}
Run Code Online (Sandbox Code Playgroud)

javascript

0
推荐指数
1
解决办法
71
查看次数

Jquery Mobile css覆盖了我的身体css

http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css覆盖了我的身体造型

<body style="margin:0; padding:0; background-image:url(img/bggradient.jpg); background-repeat:repeat-x">
Run Code Online (Sandbox Code Playgroud)

显然我使用的颜色F6F6F6在那个css文件中出现了12次,我觉得很难读.我怎么能在这里重新覆盖身体造型?

css jquery

-2
推荐指数
1
解决办法
2203
查看次数

标签 统计

javascript ×2

css ×1

http-post ×1

jquery ×1