Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.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
CSS Twitter引导覆盖JavaScript样式,因为它在脚本之后执行。最后如何执行脚本?_Javascript_Jquery_Html_Css_Twitter Bootstrap - Fatal编程技术网

CSS Twitter引导覆盖JavaScript样式,因为它在脚本之后执行。最后如何执行脚本?

CSS Twitter引导覆盖JavaScript样式,因为它在脚本之后执行。最后如何执行脚本?,javascript,jquery,html,css,twitter-bootstrap,Javascript,Jquery,Html,Css,Twitter Bootstrap,因此,我正在向父页面发送iframe消息。iframe的内容发送一条带有宽度和高度的POST消息,我在收到消息后抓取它们来更改元素的样式。然而,每当我这样做时,twitter引导就会改变元素的样式(我只能假设这是一个时间问题) 我尝试包装消息侦听器的功能,但代码永远不会执行。这是: window.addEventListener("message", function(event) { window.onload = function() {

因此,我正在向父页面发送iframe消息。iframe的内容发送一条带有宽度和高度的POST消息,我在收到消息后抓取它们来更改元素的样式。然而,每当我这样做时,twitter引导就会改变元素的样式(我只能假设这是一个时间问题)

我尝试包装消息侦听器的功能,但代码永远不会执行。这是:

        window.addEventListener("message", function(event) {
            window.onload = function() {
                console.log("loaded");
                var array = event.data.split(" ");
                addStyle(document.getElementById("outer-frame-form"), 
                    ['height', 'width', 'position', 'overflow'], 
                    [array[0],array[1],'relative','hidden'], 
                    true);
            }
        });

        function addStyle(element, properties, values, important) {
            // this will be run when the whole pa
                var i;
                var cssString = "";
                for (var i=0; i<properties.length; i++)
                {
                    //remove previously defined property
                    if (element.style.setProperty)
                        element.style.setProperty(properties[i], '');
                    else
                        element.style.setAttribute(properties[i], '');

                    cssString += properties[i] + ':' + values[i] + ((important) ? ' !important' : '') + '; '
                    console.log(properties[i]);
                }

                //insert the new style with all the old rules
                element.setAttribute('style', element.style.cssText + " " + cssString);
        }
window.addEventListener(“消息”,函数(事件){
window.onload=函数(){
控制台日志(“已加载”);
var数组=event.data.split(“”);
addStyle(document.getElementById(“外部框架形式”),
[‘高度’、‘宽度’、‘位置’、‘溢出’],
[数组[0]、数组[1]、“相对”、“隐藏”],
正确的);
}
});
函数addStyle(元素、属性、值、重要){
//这将在整个pa运行时运行
var i;
var cssString=“”;

对于(var i=0;i我认为您可能过于复杂了。在模板的某个地方,您将有一个标题标记-这是加载引导的地方。请将您的标题标记放在下面-它的“级联样式表”,以便最后一个样式表具有优先权,并且高度和宽度仍然会被覆盖。