从jQuery中的另一个函数获取参数的值

时间:2013-04-03 15:18:42

标签: jquery html

下面是我的JavaScript函数,它从查询字符串中获取“id”的值。

function getQueryStringValue() {
            var name = "id";
            name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            var regexS = "[\\?&]" + name + "=([^&#]*)";
            var regex = new RegExp(regexS);
            var results = regex.exec(window.location.search);
            if (results == null)
                return "";
            else
                return decodeURIComponent(results[1].replace(/\+/g, " "));
        }

这是我用来录制视频的jquery函数:

 $(document).ready(function () {
            $("#webcam").scriptcam({
                fileReady: fileReady,
                cornerRadius: 20,
                cornerColor: 'e3e5e2',
                onError: onError,
                promptWillShow: promptWillShow,
                showMicrophoneErrors: false,
                onWebcamReady: onWebcamReady,
                setVolume: setVolume,
                timeLeft: timeLeft,
                fileName: 'demofilename',//This needs to be taken from "getQueryStringValue()"
                connected: showRecord
            });
            setVolume(0);
            $("#slider").slider({ animate: true, min: 0, max: 100, value: 50, orientation: 'vertical', disabled: true });
            $("#slider").bind("slidechange", function (event, ui) {
                $.scriptcam.changeVolume($("#slider").slider("option", "value"));
            });
        });

我想从函数“getQueryStringValue”获取文件名。目前它的硬编码如下:

fileName: 'demofilename'

我怎样才能实现它?

1 个答案:

答案 0 :(得分:0)

...
fileName: getQueryStringValue(),
...