我的目标是使用以下方法执行PhantomJS:
// adding $op and $er for debugging purposes
exec('phantomjs script.js', $op, $er);
print_r($op);
echo $er;
Run Code Online (Sandbox Code Playgroud)
然后在内部script.js,我计划使用多个page.open()来捕获不同页面的屏幕截图,例如:
var url = 'some dynamic url goes here';
page = require('webpage').create();
page.open(url, function (status) {
console.log('opening page 1');
page.render('./slide1.png');
});
page = require('webpage').create();
page.open(url, function (status) {
console.log('opening page 2');
page.render('./slide2.png');
});
page = require('webpage').create();
page.open(url, function (status) {
console.log('opening page 3');
page.render('./slide3.png');
phantom.exit(); //<-- Exiting phantomJS only after opening all 3 pages
});
Run Code Online (Sandbox Code Playgroud)
在运行时exec,我在页面上得到以下输出:
Array ( …Run Code Online (Sandbox Code Playgroud) 现在我正在使用以下命令来运行 phantomJS
exec('./phantomjs table.js',$op,$er);
Run Code Online (Sandbox Code Playgroud)
var page = require('webpage').create();
page.open('table.php', function () {
page.render('table.png');
phantom.exit();
});
Run Code Online (Sandbox Code Playgroud)
这符合目的.但现在我需要使用动态变量,即date.那么是否可以在exec命令行中传递PHP或Javascript变量,以便我可以在里面使用该变量table.js?
我尝试根据此处发布的解决方案修改我的代码.通过exec将变量传递给PhantomJS
exec('./phantomjs table.js http://www.yahoo.com',$op,$er);
Run Code Online (Sandbox Code Playgroud)
var args = require('system').args;
var page = require('webpage').create();
var address = system.args[1];
page.open(address, function () {
page.render('table.png');
phantom.exit();
});
Run Code Online (Sandbox Code Playgroud)
但这导致了两个问题:
如果我删除修改后的代码,一切都按预期工作.
在table.js里面我用过这个:
var args = require('system').args;
args.forEach(function(arg, i) {
console.log(i+'::'+arg);
});
var page = require('webpage').create();
var address = 'http://www.gmail.com';
page.open(address, function () { …Run Code Online (Sandbox Code Playgroud) 我在页面加载时运行了两个ajax调用.如果我在桌面浏览器中打开页面,它们都会按预期工作.
但是,如果我在Android浏览器(例如Chrome)中打开相同的页面,我注意到第二个ajax函数的响应正在等待第一个ajax函数的完成,这有点挫败了异步的目的.两者都是并发执行,但第二个函数success仅在第一个ajax调用success函数完成后执行.

事实上它在桌面浏览器中工作而不是在Android浏览器中工作,这让我相信在android中必须有某种设置阻止并发异步调用.
如果是这种情况,我可以禁用它吗?我的代码如下btw:
$(function(){
var intervalID = window.setInterval(function(){
doAjax(); // this is the function which is waiting for completion of first ajax call
}, 2000);
// the first ajax call
$.ajax({
type:'post',
url:'progress-insert.php', // basically is meant for insertion of records into db
success:function(data)
{
clearInterval(intervalID);
}
});
function doAjax()
{
$.ajax({
type:'post',
url:'progress-update.php', // basically returns how many records have been inserted so far
success:function(data)
{
// do something
}
}); …Run Code Online (Sandbox Code Playgroud) 嗨我在每个页面上都有我的网站上的菜单,我想把它放在它自己的menu.php文件中,但我不知道如何为我所在的任何页面设置class ="active".这是我的代码:请帮帮我
menu.php:
<li class=" has-sub">
<a class="" href="javascript:;"><i class=" icon-time"></i> Zeiten<span class="arrow"></span></a>
<ul class="sub">
<li><a class="" href="offnungszeiten.php">Öffnungszeiten</a></li>
<li><a class="" href="sauna.php">Sauna</a></li>
<li><a class="" href="frauensauna.php">Frauensauna</a></li>
<li class=""><a class="" href="custom.php">Beauty Lounge</a></li>
<li><a class="" href="feiertage.php">Feiertage</a></li>
</ul>
</li>
Run Code Online (Sandbox Code Playgroud) 让我首先说明我不是来自C背景.我是一名PHP开发人员.所以我到目前为止所编写的所有内容都是通过从其他示例中获取一些零碎的东西并对其进行微调以满足我的要求.所以,如果我提出过于基本或明显的问题,请耐心等待.
我开始FFmpeg使用CreateProcess()了
int startFFmpeg()
{
snprintf(cmd, sizeof(cmd), "D:\\ffpmeg\bin\ffmpeg.exe -i D:\\video.mpg -r 10 D:\\frames");
PROCESS_INFORMATION pi;
STARTUPINFO si={sizeof(si)};
si.cb = sizeof(STARTUPINFO);
int ff = CreateProcess(NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
return ff;
}
Run Code Online (Sandbox Code Playgroud)
我需要做的是获取该PID过程,然后稍后检查一段时间后它是否仍在运行.这基本上就是我要找的东西:
int main()
{
int ff = startFFmpeg();
if(ff)
{
// great! FFmpeg is generating frames
// then some time later
if(<check if ffmpeg is still running, probably by checking the PID in task manager>) // …Run Code Online (Sandbox Code Playgroud) 在试验时,我遇到了这个.
<div id="result"></div>
<script type="text/javascript">
$('#result').html(['<p>This is inside an array</p>', '<em>This is second item in array</em>']);
</script>
Run Code Online (Sandbox Code Playgroud)
当页面被重新加入时,我可以在浏览器控制台中看到以下标记:
<div id="result">
<p>This is inside an array</p>
<em>This is second item in array</em>
</div>
Run Code Online (Sandbox Code Playgroud)
这是否意味着array.join("")如果提供的参数/参数jQuery正在后台运行.html()方法是一个数组?
我在文档中找不到这个,因此很想知道更多.
为了改善用户体验,我计划在我的网站的所有页面上使用字体大小增加/减少/重置工具(A-,A,A +)
我面临的问题是页面上不同元素使用的字体大小不均匀.有些是14px,有些是18px,有些是12px,有些是15px.
因此,使用body标记来操作字体大小将无法获得所需的结果.
是否有一个解决方案将遍历每个元素(获取其当前大小)并将其字体大小增加1(如果A+单击)或将大小减小1(如果A-单击)并重置为原点(如果A单击)?
PS:我也对jQuery解决方案持开放态度.
考虑一个标记,如
<select id="blah">
<option value="3">Some text</option>
<option value="4">Some text</option>
<option value="8">Some text</option> // <---- target this tag based on value 7
<option value="19">Some text</option>
</select>
Run Code Online (Sandbox Code Playgroud)
假设我有一个值,比如说7.是否可以定位其value属性最接近7 的选项标签,在这种情况下,它将是<option value="8">?
我知道^哪个意味着从哪个开始,$哪个意味着结束,并希望是否有这样的东西来找到给定值的最接近的匹配.
到目前为止,我已按照文档设法获得了按钮的click事件.我现在正在努力的是以编程方式触发ADF组件的click事件.
源代码如下:
<af:showDetailItem id="pane1" text="Panel Label 1" disclosed="true">
<af:commandButton text="commandButton 1" id="cb1">
<af:clientListener method="showNext" type="action" />
</af:commandButton>
</af:showDetailItem>
<af:showDetailItem id="pane2" text="Panel Label 2">
<af:commandButton text="commandButton 2" id="cb2">
<af:clientListener method="showNext" type="action" />
</af:commandButton>
</af:showDetailItem>
<af:showDetailItem id="pane3" text="Panel Label 3">
<af:commandButton text="commandButton 3" id="cb3">
<af:clientListener method="showNext" type="action" />
</af:commandButton>
</af:showDetailItem>
Run Code Online (Sandbox Code Playgroud)
使用Javascript
function showNext(evt){
var src = evt.getSource();
var showDetailItemNode = src.getParent(); // targets the showDetailItem tag
/* how do I trigger the click event of this node */
}
Run Code Online (Sandbox Code Playgroud)
所以我基本上想要实现的是,当点击按钮#cb1时,我想模拟showDetailItem#pane1的click事件,依此类推......
我要在表单中实现"添加新行"功能.表单的结构类似于:
<table>
<tr>
<td><input type="text" name="v1[label]" /></td>
<td><input type="text" name="v1[observation]" /></td>
<td><input type="text" name="v1[remarks]" /></td>
</tr>
<tr>
<td><input type="text" name="v2[label]" /></td>
<td><input type="text" name="v2[observation]" /></td>
<td><input type="text" name="v2[remarks]" /></td>
</tr>
<tr>
<td colspan="3">
<input type="button" id="addrow" value="Add One More Row">
<input type="submit" name="proceed" value="Submit" />
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
如图所示,每行都有v[]数量增加.v1,v2 ......依此类推
我在寻找什么
单击"添加一行"按钮时,应执行以下操作
我做了什么
我最接近的是使用jQuery's clone().这确实完美地添加了行.但是我发现很难找到一种方法,每次单击按钮时都会将name属性的值增加1.
当下正在使用的jquERY
$('input:button[id="addrow"]').click(function(){
var secondlast = $('table tr:last').prev('tr');
secondlast.clone().insertBefore(secondlast);
});
Run Code Online (Sandbox Code Playgroud)
如果我单击该按钮两次,我将添加以下HTML
<tr>
<td><input type="text" name="v2[label]" /></td> …Run Code Online (Sandbox Code Playgroud)