我只有两个版本的网站
一个是支持Flash的设计(如桌面),另一个是移动设备
我只是想知道我是否可以检测到,如果是真的(支持)他们将保持相同的网站假设是http://mywebsite.com但链接将显示http://mywebsite.com/?flash=true,如果不支持我将重定向到http://mywebsite.com/?flash=false
抱歉愚蠢的问题,你不必给我一个答案,但如果你能提供一些资源,我可以在哪里挖掘信息并自己研究
谢谢.
我在运行node.js服务器时遇到编译错误.
我们使用OPTIMIZEJS这是一个require.js插件来编译它,在node.js中这个模块叫做requirejs-middleware.
运行服务器时的问题我收到此错误.
compilation failed for /tmp/serve.js:
Error: ReferenceError: document is not defined
In module tree:
serve
modules
editor/module
editor/editor
editor/trackevent
l10n
core/localized
at eval (eval at <anonymous> (/Users/alihuta2002/work/servejs/node_modules/requirejs-middleware/node_modules/requirejs/bin/r.js:22404:38), <anonymous>:6:21)
Run Code Online (Sandbox Code Playgroud)
所以我怀疑问题可能是这个文件与使用文件?
define( [ "../util/xhr" ], function( xhr ) {
var _strings,
_readyCallback,
_isReady = false;
function ready( json ) {
_readyCallback = _readyCallback || function(){};
function domReady() {
// If the DOM isn't ready yet, repeat when it …Run Code Online (Sandbox Code Playgroud) 我目前正在使用它来检测访问者是否安装了闪存,如果没有立即我假设他们是iPhone用户但是现在它似乎并不总是像我希望的那样工作,因为有时他们被重定向到我的网站的Flash版本,有时安装了Flash的人也重定向到我的网站的iPhone版本
<!DOCTYPE html>
<html>
<head>
<script src="http://www.featureblend.com/flash_detect_1-0-4/flash_detect.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
if(!FlashDetect.installed){
window.location = "?flash=false";
}else{
window.location = "?flash=true";
}
</script>
</head>
Run Code Online (Sandbox Code Playgroud)
问题是我如何检测它们是否像iPhone/iPad/iPod/AppleTV那样并将它们重定向到flash = false URL,如果它们不属于上述类型,将重定向到flash = true?
我试图找到但实际上找不到我想要的确切内容
谢谢你们和Merry X'Mas给大家.
<select ng-model="item.value" ng-options="item.name for item in items">
</select>
Run Code Online (Sandbox Code Playgroud)
以上将填充AngularJS中的选择选项,但selected如果满足条件,我该如何添加?
我想做这样的事情:
<select ng-model="item.value" ng-options="item.name for item in items" if="item.name == someValueToCheckAgainst" selected endif>
</select>
Run Code Online (Sandbox Code Playgroud)
显然上面是错误的,但我试图搜索这个以确定是否可以做到.
这是物品
var items = [ 'a', 'b', 'c' ];
var someValueToCheckAgainst = 'b';
Run Code Online (Sandbox Code Playgroud)
所以我的菜单应该是这样的
<select ng-model="item.value">
<option value="a">a</option>
<option value="b" selected>a</option>
<option value="c">a</option>
</select>
Run Code Online (Sandbox Code Playgroud) 您可以使用express从 reuqested 路由中获取 node.js 中的其余路径吗?
假设我的服务器在端口上8080,我只是访问http://example.com:8080/get/path/to/file
var url = require("url");
app.get("/get/*", function(req, res) {
console.log(req.path);
// this will return
// '/get/path/to/file'
console.log(url.parse(req.path);
// this will return
// protocol: null,
// slashes: null,
// auth: null,
// host: null,
// port: null,
// hostname: null,
// hash: null,
// search: null,
// query: null,
// pathname: '/get/path/to/file',
// path: '/get/path/to/file',
// href: '/get/path/to/file' }
});
Run Code Online (Sandbox Code Playgroud)
我在这里想要的是返回path/to/file有没有办法得到它?还是我的app.get()路线错了?
我知道有办法用去做regex,split,substring …
<script type='text/javascript'>
//<![CDATA[
for(var j = 0; j < 6;) {
document.writeln(++j);
}
//]]>
</script>
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,如果引用了该定义,它假设给出一个新行 The writeln() method is identical to the write() method, with the addition of writing a newline character after each statement.
但就我而言,输出是 123456
更新:
我会找到最好的答案接受,但所有的答案都是正确的,我相信下次有人会有同样的问题,所以我想我应该更新顶部的答案并删除家庭作业标签,这样这将使每个人受益.
不生成新行的原因是因为它实际上产生'\n'
浏览器的'\n'如果我没有错,它不会影响如何显示到屏幕上但是如果你查看页面的源代码,你会看到我的输出会显示这样的东西
1
2
3
4
5
6
Run Code Online (Sandbox Code Playgroud)
但是如果我们希望它将它显示到页面上,我们就必须添加<br\>标签,这样它就会生成一个标签,break-line这样我们就可以得到我们想要的相同输出.
<script type='text/javascript'>
//<![CDATA[
for(var j = 0; j < 6;) {
document.writeln(++j);
document.writeln("<br>");
}
//]]>
</script>
Run Code Online (Sandbox Code Playgroud) 我的nodejs服务器上有一个API,它将返回一个数组.
[
"123_ayesha098",
"3ar7hkung",
"aali",
"Abdelhak",
"adityaputra",
"adraga",
"agnusdark",
"ahkeno",
"ahmedjubayer",
"ahsan_hq",
"akenygren",
"alexfuser",
"alexlakatos",
"alexxed",
"alfasst",
"amaciel"
...
...
]
Run Code Online (Sandbox Code Playgroud)
我正在尝试显示此列表
<div class="list-group" ng-repeat="name in contributors">
<!-- Links to detail level -->
<a href="#/contributors/{{ name }}" class="list-group-item">
<strong>Contributor: </strong> {{ name }} <br>
</a>
</div>
Run Code Online (Sandbox Code Playgroud)
它正在显示这样
Contributor: {"0":"1","1":"2","2":"3","3":"_","4":"a","5":"y","6":"e","7":"s","8":"h","9":"a","10":"0","11":"9","12":"8"}
Contributor: {"0":"3","1":"a","2":"r","3":"7","4":"h","5":"k","6":"u","7":"n","8":"g"}
Contributor: {"0":"a","1":"a","2":"l","3":"i"}
Contributor: {"0":"A","1":"b","2":"d","3":"e","4":"l","5":"h","6":"a","7":"k"}
Contributor: {"0":"a","1":"d","2":"i","3":"t","4":"y","5":"a","6":"p","7":"u","8":"t","9":"r","10":"a"}
Contributor: {"0":"a","1":"d","2":"r","3":"a","4":"g","5":"a"}
Run Code Online (Sandbox Code Playgroud)
如何在这里正确显示它们?
这样做之后
<pre>{{ contributors | json }}</pre>
Run Code Online (Sandbox Code Playgroud)
我在页面中看到了这个
[
{
"0": "1",
"1": "2",
"2": "3",
"3": "_",
"4": "a",
"5": …Run Code Online (Sandbox Code Playgroud) /* Problem 50 */
#include <iostream>
using namespace std;
class a {
char ach;
public:
a(char c) { ach = c - 1; }
~a(); // defined below
virtual void out(ostream &os) {
if ('m' < ach)
os << ach << char(ach+7) << char(ach+6) << ' ';
else
os << ach << ach << ach;
}
};
class b: public a {
char bach;
public:
b(char c1, char c2) : a(c1) { bach = c2-1; }
void out(ostream &os) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试让我的Raspberry Pi目前连接到蓝牙扬声器,每天按计划播放音频文件,我的cron工作正在更新,@daily以获得新的时间(这基本上是祈祷)
crontab -l
@daily /home/pi/athan/update_prayers.sh
39 05 27 2 * /home/pi/athan/call_prayer.sh >/dev/null 2>&1 #fajr
31 12 27 2 * /home/pi/athan/call_prayer.sh >/dev/null 2>&1 #dhuhr
34 15 27 2 * /home/pi/athan/call_prayer.sh >/dev/null 2>&1 #asr
05 18 27 2 * /home/pi/athan/call_prayer.sh >/dev/null 2>&1 #maghrib
24 19 27 2 * /home/pi/athan/call_prayer.sh >/dev/null 2>&1 #isha
Run Code Online (Sandbox Code Playgroud)
所以,以上是我现在所拥有的,这是内容 /home/pi/athan/update_prayers.sh
#!/bin/bash
/home/pi/.nvm/versions/node/v7.5.0/bin/node /home/pi/athan/set_prayer.js
Run Code Online (Sandbox Code Playgroud)
基本上我set_prayer.js只是使用这个https://www.npmjs.com/package/crontab模块来设置crontab,我能够每天更新它没问题.现在我正在Mplayer播放音频,这是我使用的命令:
/home/pi/athan/call_prayer.sh
#!/bin/bash
/usr/bin/mplayer /home/pi/athan/athan.mp3
Run Code Online (Sandbox Code Playgroud)
我的问题是,当cron作业运行的时候没有声音或我甚至不知道作业是否正在运行,但是当我手动执行时,我可以听到正在播放的音频没问题.我也尝试在这里直接运行它/usr/bin/omxplayer -o alsa /home/pi/athan/athan.mp3而不是运行bash脚本,它似乎不适用于cron,但直接运行命令时工作正常.
在PHP中我记得我可以做类似的事情
substr(string,start,length)
现在我宣布
int array[20];
如何在不使用for循环的情况下仅打印部分内容
例如.
cout << array[1 to 5] << "Here is the breaking point" << array[15 to 20] << endl;
像这样的东西
我还记得是否printf会有类似^5或类似于说到5的东西
javascript ×3
angularjs ×2
c++ ×2
detect ×2
flash ×2
node.js ×2
bash ×1
cout ×1
cron ×1
destructor ×1
express ×1
inheritance ×1
iphone ×1
logic ×1
raspberry-pi ×1
redirect ×1
requirejs ×1
substr ×1