我正在使用一個美妙的插件computedstyle.js來獲取計算出的對象風格。 它允許我操縱通常無法做到的事情的CSS,比如構造圖像。Firefox對Safari和Chrome使用不同的jQuery變量值
我可以拍攝鏈接中找到的圖像源,並更改外殼div和圖像本身的大小。通常你只能知道圖像的大小。
- 我構造圖像
- 我尺寸的圖像
- 我然後尺寸圍繞它的IFRAME,基於改變圖像的大小。
這適用於Chrome和Safari,但當然不是Firefox,在我看來它正在迅速成爲新的Internet Explorer。
這個問題,有沒有一種方法可以讓Firefox等待注意到這個改變,然後再調整iframe的大小?
若要在Chrome和Safari中正常使用,請轉至http://syndex.me。並不正確,Firefox。
不是必須的問題,但如果你想知道我在做什麼,我將刪除Tumblrs Photoset Post的默認庫預覽,並用單個圖像替換它。
if($(this).find('.html_photoset').length){
$(".html_photoset").find("iframe").load(function(){
var myFrame=$(this);
$(this).contents().find('.photoset_row:not(:first-child)').each(function(){
$(this).remove();
})
var psPre = $(this).contents().find('.photoset_row').find('a').attr("href");
$(this).contents().find('.photoset_row').children(':not(:first-child)').remove();
$(this).contents().find('.photoset_row').children(':first-child').children().remove();
$(this).contents().find('.photoset_row').find('a').append("<img src='"+psPre+"'alt='Cover Page' />");
$(this).contents().find('img').load(function(){
var myCSS = $(this).getCSS(); //this is the plugin function
var myY = myCSS.height.slice(0, - 2);
var myX = myCSS.width.slice(0, - 2);
$(this).closest(".photoset_row").css({height: myY});
$(this).closest(".photoset_row").css({width: myX});
$(this).css({maxHeight: (heightRef-0)});
$(this).css({maxWidth: "auto"});
//after I've made the fixes to the image, I redo it for the iframe:
var myCSS2 = $(this).getCSS();
var myY2 = myCSS2.height.slice(0, - 2);
var myX2 = myCSS2.width.slice(0, - 2);
myFrame.height(myY2);
myFrame.width(myX2);
console.log(myY2);
})
})
}
如果你變得「習慣」Chrome和Safari,我會說你變得易於Webkit。 Firefox不是Webkit瀏覽器。擴大你的視野。 ':)' –
夠公平的,但這不是一個webkit插件,它是jQuery。其實我相信moz甚至有一些其他瀏覽器沒有的內部計算風格的操縱器,所以我不得不去插件路線。 – RGBK
當涉及到jQuery時,我不知道「webkit plugin」是什麼意思。瀏覽器支持特定的功能,或者它不支持*和*該功能由代碼/標記支持,試圖操縱它。 –