Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/460.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将javascript变量插入javascript函数_Javascript_Function_Variables - Fatal编程技术网

将javascript变量插入javascript函数

将javascript变量插入javascript函数,javascript,function,variables,Javascript,Function,Variables,我希望有人能帮助我,因为我现在很难办。我使用speedo popup显示弹出窗口,但我希望它始终显示在屏幕的右下角。我找到了(多亏了比我聪明的人)代码来识别某人浏览器的像素,我计算了弹出窗口正确显示需要减去多少像素,并计算了它的变量,但现在我需要将该变量写入speedo popup函数,以便它弹出到正确的位置 我需要将“h”和“w”变量的值放在下面函数语句中“top:”和“left:”部分的右侧 我希望这是有道理的。感谢您的帮助。多谢各位 代码包括以下内容: <script type="t

我希望有人能帮助我,因为我现在很难办。我使用speedo popup显示弹出窗口,但我希望它始终显示在屏幕的右下角。我找到了(多亏了比我聪明的人)代码来识别某人浏览器的像素,我计算了弹出窗口正确显示需要减去多少像素,并计算了它的变量,但现在我需要将该变量写入speedo popup函数,以便它弹出到正确的位置

我需要将“h”和“w”变量的值放在下面函数语句中“top:”和“left:”部分的右侧

我希望这是有道理的。感谢您的帮助。多谢各位

代码包括以下内容:

<script type="text/javascript">
// JavaScript
function jsUpdateSize(){
    // Get the dimensions of the viewport
    var width = window.innerWidth ||
        document.documentElement.clientWidth ||
        document.body.clientWidth;
    var height = window.innerHeight ||
        document.documentElement.clientHeight ||
        document.body.clientHeight;

    document.getElementById('jsWidth').innerHTML = width;
    document.getElementById('jsHeight').innerHTML = height;

    var w;
    var h;
    w=width-580;
    h=height-270;
    document.getElementById('w1').innerHTML = w;
    document.getElementById('h1').innerHTML = h;
};

window.onload = jsUpdateSize;       // When the page first loads
window.onresize = jsUpdateSize;     // When the browser changes size

$(function () {
    $.fn.speedoPopup({
        //htmlContent: "",
        theme: "metro",
        width:500,
        height:200,
        href: "http://delanceyplace.com/subscribe_iframe.php",
        autoShow: 1000,
        //left:956,
        //top:492
        responsive: true,
        effectIn: 'slideBottom',
        effectOut:'slideBottom',                
    });
});
</script>

//window.onresize=jsUpdateSize;//当浏览器改变大小时,您能否指定右/下而不是左/上

$.fn.speedoPopup({
    //htmlContent: "",
    theme: "metro",
    width:500,
    height:200,
    href: "http://delanceyplace.com/subscribe_iframe.php",
    autoShow: 1000,
    //left:956,
    //top:492
    bottom: 0,
    right: 0,
    responsive: true,
    effectIn: 'slideBottom',
    effectOut:'slideBottom',                
    });
});
$.fn.speedopup({…});将只调用一次。因此,在“调整大小”事件之后,您必须删除当前的一个(或更新其位置)

我会在更新函数中调用jQuery插件

下面是一个精简的示例,它使用函数.bind(…)将宽度和高度附加为“this”对象

function update() {
    var w = window.innerWidth;
    var h = window.innerHeight;
    $(function() {
        $("#o").text(this.width + " / " + this.height);
    }.bind({width: w, height: h}));
}
window.onload = update;
window.onresize = update;

它没有右或下选项,但在创建后可能会被css或脚本侵入,或者编辑插件的源代码。我知道你做了什么,但今晚我有点笨,我如何将这些值输入speedo popup的函数语句中?非常感谢。@user3022448-您只需替换$(“#o”)。文本。。。与jQuery保持一致。首先使用this.width和this.height为那些width:和height:参数创建配置对象--var config={width:this.width,height:this.height,…}--然后--$.fn.speedopoppup(配置)--
function update() {
    var w = window.innerWidth;
    var h = window.innerHeight;
    $(function() {
        $("#o").text(this.width + " / " + this.height);
    }.bind({width: w, height: h}));
}
window.onload = update;
window.onresize = update;