我怎样才能得到windowWidth,windowHeight,pageWidth,pageHeight,screenWidth,screenHeight,pageX,pageY,screenX,screenY将在所有主要浏览器工作?

在Firefox,WebKit和Internet Explorer中使用的窗口调整大小事件的正确(现代)方法是什么?
你可以打开/关闭两个滚动条吗?
我正在建立专门针对移动设备的网站.特别是有一个页面,最好以横向模式查看.
有没有办法检测访问该页面的用户是否在纵向模式下查看它,如果是,则显示一条消息,通知用户该页面最好以横向模式查看?如果用户已在横向模式下查看,则不会显示任何消息.
所以基本上,我希望网站检测视口方向,如果方向是纵向,则显示警告消息,告知用户该页面在横向模式下最佳查看.
非常感谢,Dan
我曾多次听说过onClick()在HTML 中使用JavaScript事件是一种不好的做法,因为它对语义不利.我想知道缺点是什么以及如何修复以下代码?
<a href="#" onclick="popup('/map/', 300, 300, 'map'); return false;">link</a>
Run Code Online (Sandbox Code Playgroud) 我有这个D3图表 - 几乎开箱即用.有没有办法让它响应并使用宽度和高度变量,innerRadius和outerRadius的百分比?我在响应式网站上工作,需要根据屏幕大小/浏览器大小进行更改.
jsfiddle:http://jsfiddle.net/BTfmH/1/
码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
html,
body {
margin:0;
padding:0;
width:100%;
height:100%;
}
.chart-container {
/* width:50%;
height:50%;*/
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
var width = 350,
height = 350,
? = 2 * Math.PI;
var arc = d3.svg.arc()
.innerRadius(100)
.outerRadius(135)
.startAngle(0);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")")
var background = …Run Code Online (Sandbox Code Playgroud) 在下面的小提琴:
http://jsfiddle.net/jamitzky/9x7aJ/
如果窗口宽度发生变化,如何更改图形的宽度?
码:
$(function () {
var d1 = [];
for (var i = 0; i < 14; i += 0.5)
d1.push([i, Math.sin(i)]);
var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];
// a null signifies separate line segments
var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];
$.plot($("#placeholder"), [ d1, d2, d3 ]);
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试监控浏览器何时进入全屏模式.
在我搜索全屏API指南的任何地方都会引用此博客.
http://robertnyman.com/2012/03/08/using-the-fullscreen-api-in-web-browsers/
这个SO答案也声称这是有效的.
这是我的jQuery代码,但它没有触发事件.
$(document).on("webkitfullscreenchange mozfullscreenchange fullscreenchange",function(){
console.log("bang!");
});
Run Code Online (Sandbox Code Playgroud)
看起来很简单,但它不会在Chrome中触发.知道我做错了什么吗?
更新:
发现了一些新的东西.这些事件仅在JavaScript调用requestFullScreenAPI 时才起作用,但如果用户按下F11则不起作用.
我是vuejs的新手,但每当我调整大小时我都试图获得窗口大小,这样我就可以将它与某个值进行比较,我需要根据屏幕大小来应用它.我也尝试使用watch属性,但不知道如何处理它,这可能是为什么它不起作用
methods: {
elem() {
this.size = window.innerWidth;
return this.size;
},
mounted() {
if (this.elem < 767){ //some code }
}
Run Code Online (Sandbox Code Playgroud) 我希望获得Web浏览器的实时屏幕分辨率作为用户RESTORE DOWN或MAXIMIZE而不刷新页面.
在html头:
<script type="text/javascript">
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
myWidth = window.innerWidth; myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
}
</script>
Run Code Online (Sandbox Code Playgroud)
在html体内:
<script type="text/javascript">
document.write('<p>' + myWidth + 'x' + myHeight + '</p>');
</script>
Run Code Online (Sandbox Code Playgroud)
它运作良好.问题是:如何在调整浏览器大小时显示宽度/高度值?就像这里http://quirktools.com/screenfly/左下角.
非常感谢!