$(this).css("width")在Safari中的ancohor标签上不起作用 [英] $(this).css("width") not working on ancohor tags in Safari

查看:208
本文介绍了$(this).css("width")在Safari中的ancohor标签上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CSS选择器为Web模板生成自定义弹出窗口-基本上,一些生产者对JS不满意,我需要一种简单的方法让他们设置弹出窗口大小等.我对这种方法的优点并不真正感兴趣,而是希望了解为什么jquery似乎无法获得CSS中定义的Safari锚点的宽度和高度.

请参阅: http://f1shw1ck.com/jquery_sandbox/csspops.html

我要问的问题:

对于选择器a.popup {width: 800px;height: 560px;}和锚点<a href="http://www.metmuseum.org/toah/hd/apol/hd_apol.htm" class="popup">African Rock Art: Apollo 11 Cave Stone (c. 25,500 - 23,500 BCE)</a>为什么是

if ($(this).css("width")) {   
windowParams.width = $(this).css("width");
}
if ($(this).css("height")) {   
windowParams.height = $(this).css("height");
}

两个属性在Safari中都归零吗?

在其他浏览器中的

onclick弹出警报:工具栏=否,目录=否,位置=否,可调整大小=是,菜单栏=否,滚动栏=是,状态=否,宽度= 800px,高度= 560px,顶部= 20,left = 240

Safari中的警报:工具栏=否,目录=否,位置=否,可调整大小=是,菜单栏=否,滚动条=是,状态=否,宽度= 0像素,高度= 0像素,顶部= 20,左侧= 640

感谢您帮助我理解.

解决方案

Andy是正确的.这里提供了一个解决方案:

获取真实的使用JavaScript的图像的宽度和高度? (在Safari/Chrome中)

I'm using CSS selectors to generate custom pop-ups for a web templates - basically, some some the producers aren't comfortable with JS and I need an easy way for them to set pop-up sizes etc. I'm not really interested in the merits of this approach, but rather wish to understand why jquery seems to be unable to get the width and height as defined in the CSS for a anchor in Safari.

See: http://f1shw1ck.com/jquery_sandbox/csspops.html

The meat of my question:

For the selector a.popup {width: 800px;height: 560px;} and the anchor <a href="http://www.metmuseum.org/toah/hd/apol/hd_apol.htm" class="popup">African Rock Art: Apollo 11 Cave Stone (c. 25,500 - 23,500 BCE)</a> why are

if ($(this).css("width")) {   
windowParams.width = $(this).css("width");
}
if ($(this).css("height")) {   
windowParams.height = $(this).css("height");
}

both properties returning as zero in Safari?

onclick pop-up alert in other browsers: toolbar=no,directories=no,location=no,resizable=yes,menubar=no,scrollbars=yes,status=no,width=800px,height=560px,top=20,left=240

alert in Safari: toolbar=no,directories=no,location=no,resizable=yes,menubar=no,scrollbars=yes,status=no,width=0px,height=0px,top=20,left=640

Thanks for helping me understand.

解决方案

Andy is correct. There is a solution offered here:

Get the real width and height of an image with JavaScript? (in Safari/Chrome)

这篇关于$(this).css("width")在Safari中的ancohor标签上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆