- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试从源 http://dougtesting.net/home 获取 winwheel ,我设置了所有内容并在 chrome 和 IE 9+ 上正常工作,但我需要让它在 IE 8 上工作。经过一番调查,我发现需要插入 excanvas.js 才能让 Canvas 在 IE 8 上工作,但它并没有解决我的问题仍然是 IE 8 显示错误“当前浏览器不支持 Canvas ”。
我的 HTML 代码:
<html>
<head>
<title>Wheel</title>
<link rel="stylesheet" href="main.css" type="text/css" />
<script type="text/javascript" src="excanvas.js"></script>
<script type="text/javascript" src="Winwheel.js"></script>
<script src="TweenMax.min.js"></script>
</head>
<body>
<div align="center">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<div class="power_controls">
<br />
<br />
<table class="power" cellpadding="10" cellspacing="0">
<tr>
<th align="center">Power</th>
</tr>
<tr>
<td width="78" align="center" id="pw3" onClick="powerSelected(3);">High</td>
</tr>
<tr>
<td align="center" id="pw2" onClick="powerSelected(2);">Med</td>
</tr>
<tr>
<td align="center" id="pw1" onClick="powerSelected(1);">Low</td>
</tr>
</table>
<br />
<img id="spin_button" src="spin_off.png" alt="Spin" onClick="startSpin();" />
</div>
</td>
<td width="421" height="564" class="the_wheel" align="center" valign="center">
<canvas id="canvas" width="420" height="420">
<p style="{color: white}" align="center">Sorry, your browser doesn't support canvas. Please try another.</p>
</canvas>
</td>
</tr>
</table>
<script>
// Create new wheel object specifying the parameters at creation time.
var theWheel = new Winwheel({
'numSegments' : 20, // Specify number of segments.
'outerRadius' : 160, // Set outer radius so wheel fits inside the background.
'drawText' : false, // Code drawn text can be used with segment images.
'textFontSize' : 16,
'textOrientation' : 'curved',
'textAlignment' : 'inner',
'textMargin' : '90',
'textFontFamily' : 'monospace',
'textStrokeStyle' : 'black',
'textLineWidth' : 3,
'textFillStyle' : 'white',
'drawMode' : 'segmentImage', // Must be segmentImage to draw wheel using one image per segemnt.
'segments' : // Define segments including image and text.
[
{'image' : '1.png', 'text' : '379013000'},
{'image' : '2.png', 'text' : '379067000'},
{'image' : '3.png', 'text' : '379021000'},
{'image' : '4.png', 'text' : 'LOST'},
{'image' : '5.png', 'text' : '800041000'},
{'image' : '6.png', 'text' : '389081000'},
{'image' : '7.png', 'text' : '508056000'},
{'image' : '8.png', 'text' : 'EARN'},
{'image' : '9.png', 'text' : '389020000'},
{'image' : '10.png', 'text' : 'TURN'},
{'image' : '11.png', 'text' : '800042000'},
{'image' : '12.png', 'text' : '389020000'},
{'image' : '13.png', 'text' : '379068000'},
{'image' : '14.png', 'text' : 'EARN'},
{'image' : '15.png', 'text' : 'LOST'},
{'image' : '16.png', 'text' : '389081000'},
{'image' : '17.png', 'text' : '370180000'},
{'image' : '18.png', 'text' : '700002000'},
{'image' : '19.png', 'text' : '379067000'},
{'image' : '20.png', 'text' : '800044000'},
],
'animation' : // Specify the animation to use.
{
'type' : 'spinToStop',
'duration' : 5, // Duration in seconds.
'spins' : 8, // Number of complete spins.
'callbackFinished' : 'alertPrize()'
}
});
// Vars used by the code in this page to do power controls.
var wheelPower = 0;
var wheelSpinning = false;
// -------------------------------------------------------
// Function to handle the onClick on the power buttons.
// -------------------------------------------------------
function powerSelected(powerLevel)
{
// Ensure that power can't be changed while wheel is spinning.
if (wheelSpinning == false)
{
// Reset all to grey incase this is not the first time the user has selected the power.
document.getElementById('pw1').className = "";
document.getElementById('pw2').className = "";
document.getElementById('pw3').className = "";
// Now light up all cells below-and-including the one selected by changing the class.
if (powerLevel >= 1)
{
document.getElementById('pw1').className = "pw1";
}
if (powerLevel >= 2)
{
document.getElementById('pw2').className = "pw2";
}
if (powerLevel >= 3)
{
document.getElementById('pw3').className = "pw3";
}
// Set wheelPower var used when spin button is clicked.
wheelPower = powerLevel;
// Light up the spin button by changing it's source image and adding a clickable class to it.
document.getElementById('spin_button').src = "spin_on.png";
document.getElementById('spin_button').className = "clickable";
}
}
// -------------------------------------------------------
// Click handler for spin button.
// -------------------------------------------------------
function startSpin()
{
// Ensure that spinning can't be clicked again while already running.
if (wheelSpinning == false)
{
// Based on the power level selected adjust the number of spins for the wheel, the more times is has
// to rotate with the duration of the animation the quicker the wheel spins.
if (wheelPower == 1)
{
theWheel.animation.spins = 3;
}
else if (wheelPower == 2)
{
theWheel.animation.spins = 8;
}
else if (wheelPower == 3)
{
theWheel.animation.spins = 15;
}
// Disable the spin button so can't click again while wheel is spinning.
document.getElementById('spin_button').src = "spin_off.png";
document.getElementById('spin_button').className = "";
// Begin the spin animation by calling startAnimation on the wheel object.
theWheel.startAnimation();
// Set to true so that power can't be changed and spin button re-enabled during
// the current animation. The user will have to reset before spinning again.
wheelSpinning = true;
}
}
// -------------------------------------------------------
// Function for reset button.
// -------------------------------------------------------
function resetWheel()
{
theWheel.stopAnimation(false); // Stop the animation, false as param so does not call callback function.
theWheel.rotationAngle = 0; // Re-set the wheel angle to 0 degrees.
theWheel.draw(); // Call draw to render changes to the wheel.
document.getElementById('pw1').className = ""; // Remove all colours from the power level indicators.
document.getElementById('pw2').className = "";
document.getElementById('pw3').className = "";
wheelSpinning = false; // Reset to false to power buttons and spin can be clicked again.
}
// -------------------------------------------------------
// Called when the spin animation has finished by the callback feature of the wheel because I specified callback in the parameters.
// -------------------------------------------------------
function alertPrize()
{
// Get the segment indicated by the pointer on the wheel background which is at 0 degrees.
var winningSegment = theWheel.getIndicatedSegment();
// Do basic alert of the segment text. You would probably want to do something more interesting with this information.
switch(winningSegment.text)
{
case "LOST": // lost 1k np
break;
case "EARN": // earn 1k np
break;
case "TURN": // do nothing
break;
default: // give item
}
}
</script>
</body>
</html>
错误显示:
http://screencast.com/t/23WeMNBXOH8N
在我看来,wheelwin 没有读取新 Canvas 。我该如何修复它?
提前致谢
最佳答案
我通过插入修复了它
<!--[if lte IE 8]><script type="text/javascript" src="themes/default/js/excanvas.js"></script><![endif]-->
完成后, Canvas 在 Internet Explorer 8 中正常工作。
下载链接:
https://github.com/arv/ExplorerCanvas/blob/master/excanvas.js
完整代码示例:
<!DOCTYPE html>
<html>
<head>
<title>Wheel</title>
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<link rel="stylesheet" href="themes/default/wheel.css" type="text/css" />
<!--[if lte IE 8]><script type="text/javascript" src="themes/default/js/excanvas.js"></script><![endif]-->
<script type="text/javascript" src="themes/default/js/Winwheel.js"></script>
<script src="themes/default/js/TweenMax.min.js"></script>
</head>
<body onload="initWinwheel();" oncontextmenu="return false" onselectstart="return false" ondragstart="return false" scroll="no">
<div align="center">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<div class="power_controls">
<br />
<br />
<table class="power" cellpadding="10" cellspacing="0">
<tr>
<th align="center">Power</th>
</tr>
<tr>
<td width="78" align="center" id="pw3" onClick="powerSelected(3);">High</td>
</tr>
<tr>
<td align="center" id="pw2" onClick="powerSelected(2);">Med</td>
</tr>
<tr>
<td align="center" id="pw1" onClick="powerSelected(1);">Low</td>
</tr>
</table>
<br />
<img id="spin_button" src="themes/default/images/wheel/spin_off.png" alt="Spin" onClick="startSpin();" />
</div>
</td>
<td width="421" height="564" class="the_wheel" align="center" valign="center">
<canvas id="canvas" width="420" height="420">
<p style="{color: white}" align="center">Sorry, your browser doesn't support canvas. Please try another.</p>
</canvas>
</td>
</tr>
</table>
<script>
var theWheel;
function initWinwheel() {
// Create new wheel object specifying the parameters at creation time.
theWheel = new Winwheel({
'numSegments' : 20, // Specify number of segments.
'outerRadius' : 160, // Set outer radius so wheel fits inside the background.
'drawText' : false, // Code drawn text can be used with segment images.
'textFontSize' : 16,
'textOrientation' : 'curved',
'textAlignment' : 'inner',
'textMargin' : '90',
'textFontFamily' : 'monospace',
'textStrokeStyle' : 'black',
'textLineWidth' : 3,
'textFillStyle' : 'white',
'drawMode' : 'segmentImage', // Must be segmentImage to draw wheel using one image per segemnt.
'segments' : // Define segments including image and text.
[
{'image' : 'themes/default/images/wheel/1.png', 'text' : '379013000'},
{'image' : 'themes/default/images/wheel/2.png', 'text' : '379067000'},
{'image' : 'themes/default/images/wheel/3.png', 'text' : '379021000'},
{'image' : 'themes/default/images/wheel/4.png', 'text' : 'LOST'},
{'image' : 'themes/default/images/wheel/5.png', 'text' : '800041000'},
{'image' : 'themes/default/images/wheel/6.png', 'text' : '389081000'},
{'image' : 'themes/default/images/wheel/7.png', 'text' : '508056000'},
{'image' : 'themes/default/images/wheel/8.png', 'text' : 'EARN'},
{'image' : 'themes/default/images/wheel/9.png', 'text' : '389020000'},
{'image' : 'themes/default/images/wheel/10.png', 'text' : 'TURN'},
{'image' : 'themes/default/images/wheel/11.png', 'text' : '800042000'},
{'image' : 'themes/default/images/wheel/12.png', 'text' : '389020000'},
{'image' : 'themes/default/images/wheel/13.png', 'text' : '379068000'},
{'image' : 'themes/default/images/wheel/14.png', 'text' : 'EARN'},
{'image' : 'themes/default/images/wheel/15.png', 'text' : 'LOST'},
{'image' : 'themes/default/images/wheel/16.png', 'text' : '389081000'},
{'image' : 'themes/default/images/wheel/17.png', 'text' : '370180000'},
{'image' : 'themes/default/images/wheel/18.png', 'text' : '700002000'},
{'image' : 'themes/default/images/wheel/19.png', 'text' : '379067000'},
{'image' : 'themes/default/images/wheel/20.png', 'text' : '800044000'},
],
'animation' : // Specify the animation to use.
{
'type' : 'spinToStop',
'duration' : 5, // Duration in seconds.
'spins' : 5, // Number of complete spins.
'callbackFinished' : 'alertPrize()'
}
});
}
// Vars used by the code in this page to do power controls.
var wheelPower = 0;
var wheelSpinning = false;
// -------------------------------------------------------
// Function to handle the onClick on the power buttons.
// -------------------------------------------------------
function powerSelected(powerLevel)
{
// Ensure that power can't be changed while wheel is spinning.
if (wheelSpinning == false)
{
// Reset all to grey incase this is not the first time the user has selected the power.
document.getElementById('pw1').className = "";
document.getElementById('pw2').className = "";
document.getElementById('pw3').className = "";
// Now light up all cells below-and-including the one selected by changing the class.
if (powerLevel >= 1)
{
document.getElementById('pw1').className = "pw1";
}
if (powerLevel >= 2)
{
document.getElementById('pw2').className = "pw2";
}
if (powerLevel >= 3)
{
document.getElementById('pw3').className = "pw3";
}
// Set wheelPower var used when spin button is clicked.
wheelPower = powerLevel;
// Light up the spin button by changing it's source image and adding a clickable class to it.
document.getElementById('spin_button').src = "themes/default/images/wheel/spin_on.png";
document.getElementById('spin_button').className = "clickable";
}
}
// -------------------------------------------------------
// Click handler for spin button.
// -------------------------------------------------------
function startSpin()
{
// Ensure that spinning can't be clicked again while already running.
if (wheelSpinning == false)
{
// Based on the power level selected adjust the number of spins for the wheel, the more times is has
// to rotate with the duration of the animation the quicker the wheel spins.
if (wheelPower == 1)
{
theWheel.animation.spins = 3;
}
else if (wheelPower == 2)
{
theWheel.animation.spins = 8;
}
else if (wheelPower == 3)
{
theWheel.animation.spins = 15;
}
// Disable the spin button so can't click again while wheel is spinning.
document.getElementById('spin_button').src = "themes/default/images/wheel/spin_off.png";
document.getElementById('spin_button').className = "";
// Begin the spin animation by calling startAnimation on the wheel object.
theWheel.startAnimation();
// Set to true so that power can't be changed and spin button re-enabled during
// the current animation. The user will have to reset before spinning again.
wheelSpinning = true;
//sendCmd2("EMPTY","-1", readCookie("CHAR"));
}
}
// -------------------------------------------------------
// Function for reset button.
// -------------------------------------------------------
function resetWheel()
{
theWheel.stopAnimation(false); // Stop the animation, false as param so does not call callback function.
theWheel.rotationAngle = 0; // Re-set the wheel angle to 0 degrees.
theWheel.draw(); // Call draw to render changes to the wheel.
document.getElementById('pw1').className = ""; // Remove all colours from the power level indicators.
document.getElementById('pw2').className = "";
document.getElementById('pw3').className = "";
wheelSpinning = false; // Reset to false to power buttons and spin can be clicked again.
}
// -------------------------------------------------------
// Called when the spin animation has finished by the callback feature of the wheel because I specified callback in the parameters.
// -------------------------------------------------------
function alertPrize()
{
// Get the segment indicated by the pointer on the wheel background which is at 0 degrees.
var winningSegment = theWheel.getIndicatedSegment();
if(winningSegment.text == "")
return;
// Do basic alert of the segment text. You would probably want to do something more interesting with this information.
switch(winningSegment.text)
{
case "LOST": // lost 1k np
sendCmd("+np_give","-1000", readCookie("CHAR"));
break;
case "EARN": // earn 1k np
sendCmd("+np_give","1000", readCookie("CHAR"));
break;
case "TURN": // do nothing
sendCmd("EMPTY","0", readCookie("CHAR"));
break;
default: // give item
sendCmd("+give_item",winningSegment.text, readCookie("CHAR"));
}
winningSegment.text = "";
}
function sendCmd(command, giveitem,character)
{
$.ajax({ url: 'https://titan.maxko.org/?page=async',
data: {cmd: command, item: giveitem, chars: character},
type: 'post',
success: function(output) {
//alert(output);
}
});
}
// Cookies
function createCookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
}
else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name, "", -1);
}
</script>
</body>
</html>
关于javascript - Winwheel IE 8 Canvas ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40518654/
我是网页设计新手。现在我遇到了我目前工作的 2 个网站的问题。我的模板只支持 Firefox 浏览器,不支持其他主流浏览器,如 IE、chrome、Opera、safari。 我试过一些 If IE
在我的 HTML 上,使用了下面的元标记来解决一些字体问题。我只想知道: 这两个元标记的含义相同吗?还是每一个都不一样? [以逗号分隔] [以分号分隔] 请解释一下。 最佳答案 Microsoft
这句话究竟是什么意思? 部分示例使用 ,分隔 IE 的版本,而有些使用 ; ;哪个是正确的? 订单IE=9; IE=8; IE=7; IE=EDGE有一些重要性,我想知道。 编辑:我正在使用 最佳答
这句话究竟是什么意思? 一些示例使用 ,分隔 IE 的版本,而有些使用 ; ;哪个是正确的? 订单IE=9; IE=8; IE=7; IE=EDGE有一定的重要性,我想知道。 编辑:我正在使用 最佳
在 IE 8 中,我们可以带出开发者工具。然后在顶部,有一个浏览器模式: IE 7 IE 8 IE 8 Compatibility View 所以如果 IE 7是强制页面显示为好像浏览器是 IE 7,
我认为不需要任何描述。我只需要我的 IE 11 单选按钮与 IE 8 中的一样,即颜色为 3-d 蓝色。在 IE 11 中,默认单选按钮是二维的,颜色为黑色。目前还没有解决这个问题。 最佳答案 检查这
我必须编写一个显示密码对话框的小程序。问题是对话框设置为始终在顶部,但是当用户单击 IE 窗口时,对话框仍然隐藏在 IE 窗口后面。并且由于对话框是模态的并且保持全部 IE 线程 IE Pane 不会
如何制作适用于所有 IE 浏览器的样式表。不只是 ie.css 中的 IE 8 本站主题的ie.css文件中只包含IE8样式。 最佳答案 他们这样做的原因是因为他们可能不支持 Internet Exp
使用有什么区别吗 ... 或者 ... ? 最佳答案 如果一种罕见的、神话般的浏览器被称为 ,就会有所不同。 Internet Explorer 6.66 被发现。 关于internet-explor
我试图在 IE7+8 中使用字体图标并遇到了一个问题,这个问题可以通过仅 IE7 的样式表轻松解决。长话短说,现在 IE7 和 IE9 都以某种方式运行我的仅 IE7 样式表(IE8 运行得很好)。我
我实现了上传的图片显示在网站上。为了 图片未正确上传意味着我将错误图片替换为 那?当我加载网站时,我遇到了 错误图像不存在的问题 定义,并且灯箱在 chrome 和 firefox 中加载 但它没有在
我有一个特殊的问题。我正在尝试“现代化”和为旧 IE 制作的旧应用程序,以便在 IE 11 中工作。但不知何故,CSS 类没有应用于 DOM 元素。 CSS 非常简单: .header { h
对于 IE 7 和 IE 8,IE 上 URL 的 2k 长度限制是否仍然存在? (后 IE 6 时代) 最佳答案 http://support.microsoft.com/kb/208427 似乎它
我们正在完善这个网站:dev.underglassframing.com 除了主要内容 div (#main) 后面的背景在 IE 7、8 和 9 中的内容之前停止外,在每个浏览器中一切都很好。我在末
我在 IE 11 中搜索过与 border-radius 相关的类似问题,但是 only one found on the Microsoft IE Developer site描述了自从“升级”到
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit th
这个问题在这里已经有了答案: (CSS?) Eliminating browser's 'selected' lines around a hyperlinked image? (5 个答案) 关闭
我知道有 1000 个问题,但我就是无法让它发挥作用。我只是想针对所有版本的 IE(包括 IE11)并给 html 一个特定的类,对于所有其他浏览器(firefox、opera、chrome),我希望
我有一个嵌入了 Internet Explorer 的程序。 在某些情况下,我需要调整嵌入式 IE 的缩放级别。我正在使用带有 OLECMDID_OPTICAL_ZOOM 的 ExecWB 命令来执行
我正在开发一个网络应用程序。我的应用程序在 chrome 和 firefox 上运行良好,但由于某种原因在 IE 中出现了一些错误。即使出现几个错误,应用程序仍然可以顺利运行,没有明显的问题。 我想对
我是一名优秀的程序员,十分优秀!