小编Ant*_*ine的帖子

将变量传递给page.evaluate - PhantomJS

是否可以在页面中传递变量.在我的情况下,我的情况如下?

function myFunction(webpage, arg1, arg2){

var page = require('webpage').create();

page.viewportSize = { width: 1920, height: 1080 };

page.open(webpage, function (status){

    if (status == 'success') {

            page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js", function(){

                page.evaluate(function(){

                    arg = arg1 + arg2;
                    console.log(arg);

                });

            });

    } 

    else { phantom.exit(); }

});

}
Run Code Online (Sandbox Code Playgroud)

我尝试了在互联网上找到的几种方法,但实际上没有什么可以得到它的变量.

预先感谢您的帮助 :)

phantomjs

22
推荐指数
1
解决办法
2万
查看次数

找不到变量 - PhantomJS

经过几个小时毫无结果的搜索,我在这里发帖.PhantomJS不允许我在下面的代码中使用变量,在运行我的脚本"无法找到变量"时出现错误消息.

你知道我的问题在哪里吗?

page.open(myurl, function (status) {

    if (status == 'success') {

        page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js", function() {

            elem = page.evaluate(function () {

                /* Select one element with jQuery */
                myElem = $('body');
                return myElem;

            })

            var elemHtml   = page.evaluate(function() { return $(elem).html(); });
            console.log(elemHtml);

        })

        phantom.exit();     

    }  

})
Run Code Online (Sandbox Code Playgroud)

谢谢=)

javascript phantomjs

12
推荐指数
1
解决办法
3万
查看次数

在画布上制作和制作波浪

我正在寻找一种在帆布设计的形状中创建波浪的方法.经过大量研究后,我发现了一些非常接近我想要的东西:

var c = document.getElementById('c'),
  ctx = c.getContext('2d'),
  cw = c.width = window.innerWidth,
  ch = c.height = window.innerHeight,
  points = [],
  tick = 0,
  opt = {
    count: 5,
    range: {
      x: 20,
      y: 80
    },
    duration: {
      min: 20,
      max: 40
    },
    thickness: 10,
    strokeColor: '#444',
    level: .35,
    curved: true
  },
  rand = function(min, max) {
    return Math.floor((Math.random() * (max - min + 1)) + min);
  },
  ease = function(t, b, c, d) {
    if ((t /= d / …
Run Code Online (Sandbox Code Playgroud)

javascript html5 canvas

4
推荐指数
2
解决办法
2万
查看次数

标签 统计

javascript ×2

phantomjs ×2

canvas ×1

html5 ×1