因为有两种获取大小的方法。从 API 级别 13 以上开始,此方法对我有用
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
Run Code Online (Sandbox Code Playgroud)
低于 14 这种方法对我有用
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth(); // deprecated
int height = display.getHeight(); // deprecated
Run Code Online (Sandbox Code Playgroud)
我可以获取所有 API 级别的屏幕大小吗???请帮助我。
当用户关闭浏览器选项卡时,我想根据他单击的选项发出 ajax 请求。
如果他点击离开此页面 -> Ajax Call 1
如果他点击 Stay on this page -> Ajax Call 2
这是我的代码现在的样子
我想在用户选择任一选项后执行此 ajax 调用。但目前,如果用户尝试关闭选项卡,ajax 调用会自动运行
window.onbeforeunload = userConfirmation;
function userConfirmation(){
var cookieName = $.trim("<?php echo $this->uri->segment('5') ?>");
var toValue = $.trim($('#toValue').val());
document.cookie = cookieName+'=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
var confirmation = 'The message will be discarded.';
$.ajax({
type: 'POST',
url: "<?php echo BASE_URL.'index.php/admin/mail_actions/deleteSessionDatas' ?>",
data: {'toValue':toValue},
dataType: 'html',
success: function(response){
console.log(response);
var response = $.trim(response);
}
});
return confirmation;
}
Run Code Online (Sandbox Code Playgroud) 我的代码有一个问题.
我从jsfiddle.net 创建了这个DEMO
单击红色div时,菜单将打开,但如果单击菜单项,菜单区域将不会关闭.
单击菜单时我需要关闭菜单区域?
<div class="p_change" tabindex="0" id="1">
<div class="pr_icon"><div class="icon-kr icon-globe"></div>CLICK</div>
<div class="pr_type">
<div class="type_s change_pri md-ripple" data-id="0"><div class="icon-pr icon-globe"></div>1</div>
<div class="type_s change_pri md-ripple" data-id="1"><div class="icon-pr icon-contacs"></div>2</div>
<div class="type_s change_pri md-ripple" data-id="2"><div class="icon-pr icon-lock-1"></div>3</div>
</div>
</div>
<div class="p_change" tabindex="0" id="2">
<div class="pr_icon"><div class="icon-kr icon-globe"></div>CLICK</div>
<div class="pr_type">
<div class="type_s change_pri md-ripple" data-id="0"><div class="icon-pr icon-globe"></div>1</div>
<div class="type_s change_pri md-ripple" data-id="1"><div class="icon-pr icon-contacs"></div>2</div>
<div class="type_s change_pri md-ripple" data-id="2"><div class="icon-pr icon-lock-1"></div>3</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
JS
$(document).ready(function() {
$('.pr_icon').on('click',function(e){
// Change Post Privacy …
Run Code Online (Sandbox Code Playgroud) 我的项目需要大约150种字体.最初加载所有字体会增加页面加载时间.
我试过谷歌搜索但找不到答案.
场景:
用户option
将从<select>
标签中选择一种字体.点击后,我必须动态检索字体,并确保浏览器呈现字体,然后使用字体避免无格式文本Flash(FOUT)
目前我正在使用AJAX
请求该字体文件
$.ajax({
type: 'GET',
url: "font-file-url",
async:false,
success: function(data) {
$("style").prepend("@font-face {\n" +
"\tfont-family: \""+fontValue+"\";\n" +
"\tsrc: local('?'), url("font-file-url") format('opentype');\n" +
"}");
}
});
Run Code Online (Sandbox Code Playgroud)
问题
我不知道浏览器何时正好呈现字体,所以我最终显示FOUT
我在Nodejs 中使用FabricJS模块。我正在尝试导出一个画布,但它不会(给我带来了困难)。我得到的只是base64 png数据。jpeg
开始的数据像
data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAYAAADL1t.....
Run Code Online (Sandbox Code Playgroud)
无论如何在nodejs中我可以将此图像转换为jpeg?我用谷歌搜索了很多,但找不到解决方案
我怀疑的是引用变量'r',引用玫瑰对象现在引用了花对象.
现在玫瑰对象发生了什么?会被摧毁吗?
我有以下代码:
class Flower
{
public void smell() // I
{
System.out.println("All flowers give smell, if you can smell");
}
}
public class Rose extends Flower
{
public void smell() // II
{
System.out.println("Rose gives rosy smell");
}
public static void main(String args[])
{
Flower f = new Flower();
Rose r = new Rose();
f = r; // subclass to super class, it is valid
f.smell(); // II
}
}
Run Code Online (Sandbox Code Playgroud) 我试图测试给定的object
匹配stored objects
是否存储并从firebase返回.如果是,则返回true或在变量中存储true.
以下是给定对象和firebase返回数据的示例
给定对象:
{name: "John", age: "32"}
Run Code Online (Sandbox Code Playgroud)
存储对象:
{
'-JrYqLGTNLfa1zEkTG5J': { name: "John", age: "32" },
'-JrkhWMKHhrShX66dSWJ': { name: "Steve", age: "25" },
'-JrkhtHQPKRpNh0B0LqJ': { name: "Kelly", age: "33" },
'-JrkiItisvMJZP1fKsS8': { name: "Mike", age: "28" },
'-JrkiPqA8KyAMj2R7A2h': { name: "Liz", age: "22" }
}
Run Code Online (Sandbox Code Playgroud) 图片的最小值width
应为300
,高度应相对于宽度成比例地缩放。
假设用户上传的图片大小为5ooX850
,我将使用
Img.set({
scaleX: 300 / Img.width,
});
Run Code Online (Sandbox Code Playgroud)
但如何扩大图像height
相对于width
?
我已经开始学习AngularJS了,这让我感到惊讶,一开始即使是四行代码都无法正常工作我也没有任何线索
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<div data-ng-app="">
<input type="text" ng-model="name='Rocky'">
Your name is {{name}}
</div>
Run Code Online (Sandbox Code Playgroud)
在文本框中键入内容时,我的表达式不会更改.
它在控制台中显示以下错误.
TypeError: r is not a function
Run Code Online (Sandbox Code Playgroud) 我在做什么:
我正在使用Fabric.js
开发画布应用程序。用户可以在画布中放置图像或文本
我想做的事:
当用户下载图像时,用户应该能够打印它。目前我正在研究 length: 5 X 8
(inches)。在 中Fabric.js
,toDataURL()
函数默认会给出72 DPI
图像,我打算用PHP
它来将其转换为300dpi
图像。
因此,要创造一个高品质的图像5X8
与300dpi
,形象应该是1500px X 2400px
。但我不能为用户提供那么多空间,因为它不会很直观。
所以,我做了以下链接中的建议
问题:
但我正面临一个麻烦。当用户放置文本或图像时,它显得非常小。当我单击文本或图像时,几乎看不到边角和边框。它考虑了画布的相对大小。请看小提琴