admin管理员组文章数量:1429027
I'm new to phantomJs. I've installed phantomjs in my system(Ubuntu) and executed a sample code "test.js" in terminal like,
test.js:
console.log("WELCOME TO PHANTOMJS");
phantom.exit();
In terminal
phantomjs test.js
its executed fine shows expected output.
NOw my question is, Is there any possibilites to execute above js file in a browser by importing that js file in a html file like,
<script src="test.js".....></script>
If is it possible means how to do?? Please help me.
I'm new to phantomJs. I've installed phantomjs in my system(Ubuntu) and executed a sample code "test.js" in terminal like,
test.js:
console.log("WELCOME TO PHANTOMJS");
phantom.exit();
In terminal
phantomjs test.js
its executed fine shows expected output.
NOw my question is, Is there any possibilites to execute above js file in a browser by importing that js file in a html file like,
<script src="test.js".....></script>
If is it possible means how to do?? Please help me.
Share Improve this question asked Oct 30, 2013 at 6:07 user2810903user2810903 711 silver badge6 bronze badges1 Answer
Reset to default 6Short Version
You can't
Detailed Version
In its current state, PhantomJS is a standalone process and needs to have the full control (in a synchronous matter) over everything: event loop, network stack, and JavaScript execution, ... yes you write scripts in Javascript but it's simply because it exposes a JavaScript API (also for coffee script).
"How to execute a nodejs module in browser?" It's pretty the same problem and you simply can't because of phantomjs/nodejs dependencies : what is webpage
module in your favorite the browser ? But it's still possibe to share pure JS library.
So, you can't directly reference a phantomjs script in your browser, but you can municate with a PhantomJS instance using HTTP GET/POST with Web Server module. HEre is a topic onInter Process Communication found on the Wiki.
本文标签: javascriptHow to execute phantomjs file browserStack Overflow
版权声明:本文标题:javascript - How to execute phantomjs file browser? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745504072a2661163.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论