Note that there are some explanatory texts on larger screens.

plurals
  1. POget value of body onload javascript with PhantomJS
    text
    copied!<p>Is there a solution to get the "<em>foo bar</em>" in JS (with jQuery ?) in this code ?</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;body role="application" onload="foo bar"&gt; &lt;div&gt;...&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I'am using <a href="http://phantomjs.org/" rel="nofollow">PhantomJS</a> in my script.</p> <p>EDIT: "<em>foo bar</em>" is an <strong>example</strong>. It's juste the value I would get.</p> <p>EDIT 2: my code (wich don't work) is <a href="http://paste.awesom.eu/nca&amp;ln" rel="nofollow">http://paste.awesom.eu/nca&amp;ln</a>.</p> <p>EDIT 3: <strong>PROBLEM(S) AND SOLUTION</strong></p> <p>After many hours I find many problems and solutions.</p> <p>First, the website is only accesible in <strong>https</strong> and I can't include jQuery file from non https url. That's why I have include the jQuery file from the website.</p> <p>I have debug this with this code :</p> <pre><code>page.onConsoleMessage = function(msg) { console.log(msg); }; </code></pre> <p>Then, I need to change my user agent because the website has a whitelist.</p> <pre><code>page.settings.userAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0'; </code></pre> <p>Finaly the code is:</p> <pre><code>page.open(url, function(status) { if ( status === "success" ) { page.includeJs(url_js_file, function() { page.evaluate(function() { console.log("&gt; " + $("body").attr("onload")); }); phantom.exit(); }); } }); </code></pre> <p>Thank you for comments and anwers.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload