The content calls says:
<html><head></head><body><pre style="word-wrap: break-word; white-spac +e: pre-wrap;"> //list of the entries in the headings drop box //the keys give the corresponding elements in the rows var leg = { aa: " ... ", ... }; </pre></body></html>
The return statement gives an error if not included in a 'function () {}'
Error while executing command: executeScript: An unknown server-side e +rror occurred while processing the command.: {"errorMessage":"Return +statements are only valid inside functions",
LanX proposal fails also:
my ($val, $type) = $js->eval_in_page('(function() {return JSON.stringi +fy(leg);})()'); print "val: $val, type: $type\n";
Gives the error
Error while executing command: executeScript: An unknown server-side e +rror occurred while processing the command.: {"errorMessage":"Can't f +ind variable: leg","request":{"headers":{"Accept":"application/json", +"Connection":"TE, close","Content-Length":"74","Content-Type":"applic +ation/json; charset=utf-8","Host":"127.0.0.1:8910","TE":"deflate,gzip +;q=0.3","User-Agent":"libwww-perl/6.15"},"httpVersion":"1.1","method" +:"POST","post":"{\"args\":[],\"script\":\"return (function() {return +JSON.stringify(leg);})()\"}","url":"/execute","urlParsed":{"anchor":" +","query":"","file":"execute","directory":"/","path":"/execute","rela +tive":"/execute","port":"","host":"","password":"","user":"","userInf +o":"","authority":"","protocol":"","source":"/execute","queryKey":{}, +"chunks":["execute"]},"urlOriginal":"/session/95efd1d0-8ea9-11e9-b043 +-85beee600173/execute"}} at C:/strawberry/perl/site/lib/Selenium/Remo +te/Driver.pm line 389.

Update:

The content seems strange to me, should the js code not be include in script tag ?


In reply to Re^2: Accessing javascript variable from perl by frazap
in thread Accessing javascript variable from perl by frazap

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.