如何来提供由浏览器的宽度不同的JavaScript文件 [英] How to serve up different javascript files by browser width

查看:105
本文介绍了如何来提供由浏览器的宽度不同的JavaScript文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我想对某些浏览器的宽度一定的JavaScript文件。我知道@media担任了每个浏览器的宽度和一些设备特定的CSS。
我怎么会做的JavaScript文件类似的东西,不需要使用服务器端的电话?

So I want certain Javascript files for certain browser widths. I know that @media serves up specific CSS per browser width and some devices. How would I do something similar for Javascript files, WITHOUT using server side calls?

时,可以使用JavaScript调用基于浏览器的宽度其他JavaScript文件?
如果是这样,怎么样?

Is is possible with Javascript to call other Javascript files based on browser width? If so, How?

先谢谢了。

推荐答案

虽然我为什么,你总是可以通过JS脚本导入JavaScript文件不能确定。

While I'm unsure on why, you can always import JavaScript files through JS Script.

以下链接给一些这方面的信息。

The following links give some information on this.

  • http://www.kevinleary.net/loadexternal-javascript-jquery-getscript/
  • http://www.stackoverflow.com/questions/1140402/how-to-add-jquery-in-js-file
  • http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml

在一个侧面说明 - 为什么你在看这样做呢?当然,你可以得到屏幕的分辨率,然后调整计算的基础上,而无需改变JS文件这些变量/内容。有这么多的不同的决议(手机不可同日而语,多显示器,宽屏幕,投影仪等)。用户还可以重新大小的浏览器有效地使这种不值得的。

ON a side note - Why are you looking at doing this? Surely you can get the resolution of the screen and then adjust calculations / content based on those variables without the need to change JS files. There are so many different resolutions (mobile devises, multiple monitors, wide screen, projectors etc.). A user can also re-size the browsers effectively making this not worth it.

这篇关于如何来提供由浏览器的宽度不同的JavaScript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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