Tag: jquery

Phantomjs page-break-after:总是创造空间

我面临phantomjs(HTML到PDF)的问题,我有1个HTML页面有16个div,我愿意在每个页面上添加分页符,但是当我添加页面中断后:总是在每个div然后在PDF中创造了很多的空间,假设当我添加2 div的空间和rest是与分页符然后空格是一点,但是当添加空间3,4,5等空间增加更多意味着每个页面有很多的空间,如何我可以解决这个,预先感谢。 这是我的代码 fs.readFile(__dirname + '/../pdf' + pdfpath, 'utf8', function (err, data) { // Render the page to variable. var html = ejs.render(data, pdfJSON); // Set this html as the content for the pdf file. page.set('content', html); var fileName = __dirname + '/pdfdata/' + f.formType + f.formId + '.pdf'; // Generate the pdf. page.render(fileName); }); […]

更改Window.print()纸张方向

我想在窗口打印上改变纸张模式(方向)。 我想改变它编程,但我找不到任何东西。 window.print() 但我不知道,我该怎么做。 @media print{@page {size: landscape}} 我不需要它。 function printWindow() { window.print({ /* some code here? */ }); }

如何在Node.js中使用JQueryselect器

我试图从硬盘中的HTML文件中提取电子邮件信息。 如果我在firefox中加载文件并运行jQuerify书签,我可以成功地使用下面的select器/函数 window.jQuery("a.iEmail").each(function(el) { console.log(window.jQuery(this).attr('href')) }); 但是在Node.js中使用这个不起作用 var document = require("jsdom").jsdom(), script = document.createElement("script"), fs = require('fs'); fs.readFile('file_1.html', 'utf-8', function(err, data){ if (err) { throw err; } // This output the document //console.log(data) var window = document.createWindow(data); script.src = 'http://code.jquery.com/jquery-1.4.2.js'; script.onload = function() { console.log(window.jQuery.fn.jquery); // outputs: 1.4.2 //console.log(window.jQuery); /* * This line works if […]

使用Ajax POST请求将图像和JSON数据发送到服务器?

我想发送一个用户从他们的机器中select的图像以及所有包装在JSON对象中的表单数据并发送到服务器。 我正在使用节点的服务器。 是否有可能将图像与其他表单元素一起放入JSON对象并在Node中读取?

从客户端请求运行带有节点的Bash脚本

当用户从浏览器中点击一个button时,我需要运行服务器端脚本。 我一直在研究一段时间,不能弄明白。 我们有什么: 运行在Fedora Red Hat上的Node.js服务器(在本地主机上) 没有PHP 大多数网页是HTML + JavaScript + jQuery 更清楚的是,这里是我们想要发生的事情: – >用户转到http:// localhost /index.html – >用户select颜色,按下“提交”button。 – >所选颜色转到bash脚本(在服务器上)./sendColors [listOfColors] – > bash脚本是这样的。 ================ 我试过的东西 child_process.spawn 我希望我可以在html页面上做到这一点: var spawn = require('child_process').spawn; ls = spawn(commandLine, [listOfColors]); ls.stdout.on('data', function (data) { console.log('stdout: ' + data); }); ls.stderr.on('data', function (data) { console.log('stderr: ' + data); }); […]

我如何在phantomJS中执行jQuery的承诺?

我正在使用试图在服务器端使用nodejs和phantomjs来search我们的网站。 虽然AJAX工作正常,我不能执行我已经在我的代码中使用自定义的承诺。 如何让幻影等待承诺解决。 以下是我编码的内容。 $('body').addClass('before-dom-ready'); $(function() { $('body').addClass('after-dom-ready'); var dfrd = $.Deferred(), promise = dfrd.promise(); setTimeout(function() { dfrd.resolve(); }, 5000); promise.done(function() { $('body').addClass('promise-executed'); }); }); phantomJS增加了“准备就绪”和“准备就绪”的课程,但是我无法获得“承诺执行”的课程。

使用jQuery AJAX与node.js,处理来自服务器的响应

这是我第一次在这里发表一个问题,我大多只是一个潜伏在其他问题上的潜伏者,但是这是我一直想弄明白的事情,而且我的生活不能。 基本上我正在做的是使用AJAX从客户端跳转到服务器,运行一些代码,search外部API给我一些数据,然后我需要这些数据返回到客户端。 这是我的代码…这是所有使用express.js的快递 客户端 $('#search').click(function(){ $.ajax({ type: "GET", url: "/search", dataType: "json" }).done (function (data) { alert(data); }); }); 服务器端 app.get('/search', function(req, res){ factual.get('/t/places',{q:'starbucks'}, function (error, data) { console.log(data); res.send(data); }); }); 现在我知道,单击#searchbutton时,它会转到服务器并成功运行该代码。 但是我不知道如何从服务器上获取这些数据,然后返回到客户端来在那里工作。 我发现其他职位提到像res.send / res.write / res.end,我已经尝试了所有这些forms的知识,我似乎永远不会将这些数据返回给客户端。 任何提示或可能更好的方法来做到这一点将非常感激。

添加bootstrap.js到browserify?

所以我想弄清楚如何做到这一点? 我通过凉亭下载了bootstrap-sass,并将bootstrap javascript添加到了一个垫片中。 有几件事让我感到困惑,bootstrap.js文件看起来像这样。 //= require bootstrap/affix //= require bootstrap/alert //= require bootstrap/button //= require bootstrap/carousel //= require bootstrap/collapse //= require bootstrap/dropdown //= require bootstrap/tab //= require bootstrap/transition //= require bootstrap/scrollspy //= require bootstrap/modal //= require bootstrap/tooltip //= require bootstrap/popover 这是一种自我解释,但同时还是令人困惑的,我是否会这样评论呢? 当我添加到引导程序shim中时,是否只包含bootstrap.js文件,还是应链接到所需的所有文件? 为了避免黑客入侵(我将在此期间进行),我想尝试获取有关如何将bootstrap.js包含到browserify中的信息。 编辑:我想我可能只需要concat所有我需要的文件,并包括该脚本,因为当我浏览bootstrap.js我刚刚得到上述。 我会尝试没有评论,那么如果失败,我会连接所有的脚本到一个文件,看看会发生什么:) 编辑:嗯看起来像concat理论的作品! 唯一的事情是jQuery,看看。 ; jQuery = global.jQuery = require("c:\\wamp\\www\\mysite\\app\\client\\requires\\jquery\\js\\jquery.js"); /* ======================================================================== […]

如何在Node.js中从ajax post返回成功

我有这样的function: exports.saveAction = function (req, res) { var conn = mysql.createConnection({ host : nconf.get("database:host"), //port: 3306, user : nconf.get("database:username"), password : nconf.get("database:password"), database : nconf.get("database:database"), multipleStatements: true, //ssl: 'Amazon RDS' }); var action = req.body; conn.query('UPDATE actions SET ? WHERE Id = ?', [action, action.Id], function (err, result) { conn.end(); if (err) throw err; res.writeHead(200, […]

在JavaScript和Node.js中为String类添加函数的性能影响是什么?

在JavaScript中为String类添加函数有什么影响? 这是一个坏主意吗? 例如, // String functions String.prototype.startsWith = function(string) { return (this.indexOf(string) === 0); } String.prototype.empty = function() { //console.log($.trim(this.valueOf())); if($.trim(this.valueOf()) == '') { return true; } else { return false; } }